Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions test/fixtures/readme-with-special-characters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
## Title with backslash `\`
test

## 4 § Toimielimet
Special char

## Урок 8. Кроссплатформенность и виртуализация
text

## Interface: SOME\_NAME<\>
method

## Version 1.10.5
bugs

## Version 1.10.6
features

## `TEXT 1`

- item 1

## `TEXT 2 ...`

TEXT 2.1 ...

## MikroTik hAP ac²

The [hAP ac²](https://mikrotik.com/product/hap_ac2) is

## acclk dac %d:[0,acclk_dac_max):dac
description

## Övningsuppgifter
swedish

## Sections
This readme causes an error `<p>` text `<h1>` more text (`</p>`)

## Тест
cyrillic

## There's an error here
bad

## Replace .gitlab-ci.yml
file name

## `this identifier`
text

## Header & noise
ampersand

## CJK。
CJK Symbols

## ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿Latin 1
Latin 1

## Instance properties inherited from [`EventEmitter`](http://nodejs.org/api/events.html)
Text
35 changes: 35 additions & 0 deletions test/transform-weird-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,38 @@ test('\nformatted headers', function (t) {

t.end()
})

test('\nrandom md characters', function (t) {
var content = require('fs').readFileSync(__dirname + '/fixtures/readme-with-special-characters.md', 'utf8');
var headers = transform(content);

t.deepEqual(
headers.toc.split('\n')
, [ '**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*',
'',
'- [Title with backslash `\\`](#title-with-backslash-)',
'- [4 § Toimielimet](#4-%C2%A7-toimielimet)',
'- [Урок 8. Кроссплатформенность и виртуализация](#%D1%83%D1%80%D0%BE%D0%BA-8-%D0%BA%D1%80%D0%BE%D1%81%D1%81%D0%BF%D0%BB%D0%B0%D1%82%D1%84%D0%BE%D1%80%D0%BC%D0%B5%D0%BD%D0%BD%D0%BE%D1%81%D1%82%D1%8C-%D0%B8-%D0%B2%D0%B8%D1%80%D1%82%D1%83%D0%B0%D0%BB%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F)',
'- [Interface: SOME\\_NAME<\\>](#interface-some_name)',
'- [Version 1.10.5](#version-1105)',
'- [Version 1.10.6](#version-1106)',
'- [`TEXT 1`](#text-1)',
'- [`TEXT 2 ...`](#text-2-)',
'- [MikroTik hAP ac²](#mikrotik-hap-ac)',
'- [acclk dac %d:[0,acclk_dac_max):dac](#acclk-dac-d0acclk_dac_maxdac)',
'- [Övningsuppgifter](#%C3%B6vningsuppgifter)',
'- [Sections](#sections)',
'- [Тест](#%D1%82%D0%B5%D1%81%D1%82)',
'- [There\'s an error here](#theres-an-error-here)',
'- [Replace .gitlab-ci.yml](#replace-gitlab-ciyml)',
'- [`this identifier`](#this-identifier)',
'- [Header & noise](#header--noise)',
'- [CJK。](#cjk)',
'- [¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿Latin 1](#%C2%AA%C2%B5%C2%BAlatin-1)',
'- [Instance properties inherited from `EventEmitter`](#instance-properties-inherited-from-eventemitter)',
'' ]
, 'generates a correct toc when readme has nameless table headers'
)

t.end()
})
2 changes: 1 addition & 1 deletion test/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ check(
, 'some main usage here'
].join('\r\n')
, [ '**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*\n\n'
, '- [My Module using \\r\\n line endings](#my-module-using-%5Cr%5Cn-line-endings)\n'
, '- [My Module using \\r\\n line endings](#my-module-using-rn-line-endings)\n'
, ' - [API](#api)\n'
, ' - [Method One](#method-one)\n'
, ' - [Method Two](#method-two)\n'
Expand Down
Loading