Skip to content

Commit

Permalink
🐛 Fix the github slugify mode (yzhang-gh#792)
Browse files Browse the repository at this point in the history
## Summary

This commit combines `baec028fcbb0a807da23aeb847ee8e4b539643c0` to `cadab204c2f28ae935498f1dddb5fdc4e3f72766`, and `f9fea764f89cc490f01e890d0a59041868dc9a89` to `2ab1a6ac17635c93aa6b863a856f55cd52e473b3`.

* ⬆ Update dependencies
  * Enable new language features:
    * ts-loader: 6.2.2 -> 8.0.3
    * typescript: 3.5.2 -> 4.0.2
  * Improve HTML entities decoding:
    * entities: 2.0.0 -> 2.0.3
  * Improve syntax highlighting when printing:
    * highlight.js: 9.15.6 -> 10.2.0
    * @types/highlight.js: 9.12.3 -> 9.12.4
  * Others are just regular upgrades.
* 🎨 Refactor function `slugify`
  * Move all the slugify functions to `slugifyMethods`.
  * Add a few comments.
* 🐛 Perform user-required case conversion before calling slugify function
* 🎨 Add type annotations to `markdownEngine.ts`
* ✨ Add `CommonmarkEngine`
* 🐛 Fix the `github` slugify function
  * Use `commonmarkEngine.engine.renderInline()`.
  * Use `entities.decodeHTML()` to decode HTML entities.
  * Correct `getTextInHtml()`.
  * Correct `PUNCTUATION_REGEXP`.
  * Add "Perform full Unicode case conversion".
* 🎨 Optimize the `gitlab` slugify function
* 🔧 Reorganize vscodeignore
* 🔧 Update metadata
  * `categories`.
  * Description of configuration.

## Known issues

"Printing" may not generate correct heading ID.

Failed cases:

```markdown
## `<em>code</em>`
## 😅
```

The second case is related to `markdown-it-emoji`. See
yzhang-gh#809 (comment)
  • Loading branch information
Lemmingh committed Sep 15, 2020
1 parent a4cea4d commit 2a23bea
Show file tree
Hide file tree
Showing 7 changed files with 470 additions and 547 deletions.
18 changes: 13 additions & 5 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
.vscode/**
.vscode-test/**
out/test/**
src/**
# Important: The patterns are relative to the location of the vscodeignore file.

# Development tools, intermediate build results, and temporary files
.vscode-test/
out/
tools/
**/*.map
.github/**

# Source files
src/
**/*.ts

# Configuration files
.github/
.vscode/
VERSION
.gitignore
tsconfig.json
Expand Down
564 changes: 194 additions & 370 deletions package-lock.json

Large diffs are not rendered by default.

93 changes: 51 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"vscode": "^1.38.0"
},
"categories": [
"Programming Languages",
"Formatters",
"Other"
],
"keywords": [
Expand Down Expand Up @@ -228,7 +230,7 @@
"markdown.extension.italic.indicator": {
"type": "string",
"default": "*",
"description": "%config.italic.indicator.description%",
"markdownDescription": "%config.italic.indicator.description%",
"enum": [
"*",
"_"
Expand Down Expand Up @@ -271,7 +273,7 @@
"one",
"ordered"
],
"enumDescriptions": [
"markdownEnumDescriptions": [
"%config.orderedList.marker.enumDescriptions.one%",
"%config.orderedList.marker.enumDescriptions.ordered%"
]
Expand All @@ -293,17 +295,17 @@
"description": "%config.print.imgToBase64.description%",
"scope": "resource"
},
"markdown.extension.print.includeVscodeStylesheets": {
"type": "boolean",
"default": true,
"description": "%config.print.includeVscodeStylesheets%"
},
"markdown.extension.print.onFileSave": {
"type": "boolean",
"default": false,
"description": "%config.print.onFileSave.description%",
"scope": "resource"
},
"markdown.extension.print.validateUrls": {
"type": "boolean",
"default": true,
"description": "%config.print.validateUrls.description%"
},
"markdown.extension.print.theme": {
"type": "string",
"default": "light",
Expand All @@ -314,10 +316,10 @@
"description": "%config.print.theme%",
"scope": "resource"
},
"markdown.extension.print.includeVscodeStylesheets": {
"markdown.extension.print.validateUrls": {
"type": "boolean",
"default": true,
"description": "%config.print.includeVscodeStylesheets%"
"description": "%config.print.validateUrls.description%"
},
"markdown.extension.syntax.decorations": {
"type": "boolean",
Expand All @@ -332,7 +334,7 @@
"markdown.extension.syntax.plainTheme": {
"type": "boolean",
"default": false,
"description": "%config.syntax.plainTheme.description%"
"markdownDescription": "%config.syntax.plainTheme.description%"
},
"markdown.extension.tableFormatter.enabled": {
"type": "boolean",
Expand All @@ -342,28 +344,22 @@
"markdown.extension.tableFormatter.normalizeIndentation": {
"type": "boolean",
"default": false,
"description": "%config.tableFormatter.normalizeIndentation.description%"
"markdownDescription": "%config.tableFormatter.normalizeIndentation.description%"
},
"markdown.extension.toc.downcaseLink": {
"type": "boolean",
"default": true,
"description": "%config.toc.downcaseLink.description%"
},
"markdown.extension.toc.slugifyMode": {
"type": "string",
"default": "github",
"enum": [
"github",
"gitlab",
"gitea",
"vscode"
],
"description": "%config.toc.slugifyMode.description%"
"markdownDescription": "%config.toc.downcaseLink.description%"
},
"markdown.extension.toc.levels": {
"type": "string",
"default": "1..6",
"description": "%config.toc.levels.description%"
"markdownDescription": "%config.toc.levels.description%"
},
"markdown.extension.toc.omittedFromToc": {
"type": "object",
"default": {},
"description": "%config.toc.omittedFromToc.description%"
},
"markdown.extension.toc.orderedList": {
"type": "boolean",
Expand All @@ -375,10 +371,27 @@
"default": false,
"description": "%config.toc.plaintext.description%"
},
"markdown.extension.toc.slugifyMode": {
"type": "string",
"default": "github",
"markdownDescription": "%config.toc.slugifyMode.description%",
"enum": [
"github",
"gitea",
"gitlab",
"vscode"
],
"enumDescriptions": [
"GitHub",
"Gitea",
"GitLab",
"Visual Studio Code"
]
},
"markdown.extension.toc.unorderedList.marker": {
"type": "string",
"default": "-",
"description": "%config.toc.unorderedList.marker.description%",
"markdownDescription": "%config.toc.unorderedList.marker.description%",
"enum": [
"-",
"*",
Expand All @@ -389,11 +402,6 @@
"type": "boolean",
"default": true,
"description": "%config.toc.updateOnSave.description%"
},
"markdown.extension.toc.omittedFromToc": {
"type": "object",
"default": {},
"description": "%config.toc.omittedFromToc.description%"
}
}
},
Expand Down Expand Up @@ -432,26 +440,27 @@
},
"dependencies": {
"@neilsustc/markdown-it-katex": "^0.5.0",
"entities": "^2.0.3",
"grapheme-splitter": "^1.0.4",
"highlight.js": "^9.15.6",
"highlight.js": "^10.2.0",
"image-size": "^0.7.4",
"markdown-it": "^10.0.0",
"markdown-it": "^11.0.1",
"markdown-it-task-lists": "^2.1.1",
"string-similarity": "^4.0.1"
"string-similarity": "^4.0.2"
},
"devDependencies": {
"@types/highlight.js": "^9.12.3",
"@types/highlight.js": "^9.12.4",
"@types/image-size": "^0.7.0",
"@types/markdown-it": "^0.0.9",
"@types/markdown-it": "^10.0.2",
"@types/mocha": "^5.2.6",
"@types/node": "^11.11.3",
"@types/node": "^12.12.58",
"@types/vscode": "1.38.0",
"glob": "^7.1.4",
"glob": "^7.1.6",
"mocha": "^7.1.1",
"ts-loader": "^6.2.2",
"typescript": "^3.5.2",
"vscode-test": "^1.2.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11"
"ts-loader": "^8.0.3",
"typescript": "^4.0.2",
"vscode-test": "^1.4.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
}
}
67 changes: 33 additions & 34 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,38 @@
"command.editing.toggleList.title": "Toggle list",
"command.editing.toggleCodeBlock.title": "Toggle code block",
"config.title": "Markdown All in One",
"config.toc.levels.description": "Range of levels for table of contents. Use `x..y` for level x to y",
"config.toc.orderedList.description": "Use ordered list (1. ..., 2. ...)",
"config.toc.unorderedList.marker.description": "Use `-`, `*` or `+` in the table of contents (for unordered list)",
"config.toc.plaintext.description": "Just plain text",
"config.toc.updateOnSave.description": "Auto update on save",
"config.toc.githubCompatibility.description": "(Deprecated) GitHub compatibility (use `slugifyMode: 'github' instead`)",
"config.toc.slugifyMode.description": "Slugify mode for TOC link generation",
"config.toc.downcaseLink.description": "Whether to downcase TOC links",
"config.toc.omittedFromToc.description": "Lists of headings to omit by project file (e.g. {\"README.md\": [\"# Introduction\"]})",
"config.list.indentationSize.description": "Whether to use different indentation sizes on different contexts. (This also affects the generated TOC)",
"config.list.indentationSize.enumDescriptions.adaptive": "Use 2 spaces for unordered list and 3 for the ordered",
"config.list.indentationSize.enumDescriptions.inherit": "Use the configured tab size of the current document (see vscode status bar)",
"config.math.enabled": "Enable basic math support (with KaTeX)",
"config.preview.autoShowPreviewToSide.description": "Auto show preview to side",
"config.orderedList.marker.description": "Ordered list marker",
"config.orderedList.marker.enumDescriptions.one": "Always use `1.` as ordered list marker",
"config.orderedList.marker.enumDescriptions.ordered": "Use increasing numbers as ordered list marker",
"config.orderedList.autoRenumber.description": "Auto fix ordered list markers",
"config.italic.indicator.description": "Use `*` or `_` to wrap italic text",
"config.tableFormatter.enabled.description": "Enable GFM table formatter",
"config.tableFormatter.normalizeIndentation.description": "Normalize table indentation to closest multiple of configured tabSize",
"config.print.absoluteImgPath.description": "Convert image path to absolute path",
"config.print.imgToBase64.description": "Convert images to base64 when printing to HTML",
"config.print.onFileSave.description": "Print current document to HTML when file is saved",
"config.print.validateUrls.description": "Enable/disable URL validation when printing",
"config.print.theme": "Theme of the exported HTML",
"config.print.includeVscodeStylesheets": "Include VSCode's basic Markdown styles so that the exported HTML looks similar as inside VSCode",
"config.syntax.decorations.description": "Add syntax decorations (e.g. ~~strikethrough~~, `code span`)",
"config.syntax.decorationFileSizeLimit.description": "If a file is larger than this size (in byte/B), we shouldn't attempt to render syntax decorations",
"config.syntax.plainTheme.description": "Only take effect when `extension.syntax.decorations` is enabled",
"config.katex.macros.description": "User-defined KaTeX macros",
"config.completion.root": "The root folder for path auto-completion",
"config.completion.respectVscodeSearchExclude": "Whether to exclude files from auto-completion using VSCode's `search.exclude` option. (`node_modules`, `bower_components` and `*.code-search` are always excluded, not affected by this option.)",
"config.completion.respectVscodeSearchExclude": "Whether to exclude files from auto-completion using VS Code's `search.exclude` setting. (`node_modules`, `bower_components` and `*.code-search` are **always excluded**, not affected by this option.)",
"config.completion.root": "The root folder for path auto-completion.",
"config.italic.indicator.description": "Use `*` or `_` to wrap italic text.",
"config.katex.macros.description": "User-defined KaTeX macros.",
"config.list.indentationSize.description": "List indentation scheme. Whether to use different indentation sizes on different list contexts or a user-defined value. (This also affects TOC generation.)",
"config.list.indentationSize.enumDescriptions.adaptive": "Use 2 spaces for unordered list and 3 for the ordered.",
"config.list.indentationSize.enumDescriptions.inherit": "Use the configured tab size of the current document. (See VS Code's status bar)",
"config.math.enabled": "Enable basic math support (Powered by KaTeX).",
"config.orderedList.autoRenumber.description": "Auto fix ordered list markers.",
"config.orderedList.marker.description": "Ordered list marker.",
"config.orderedList.marker.enumDescriptions.one": "Always use `1.` as ordered list marker.",
"config.orderedList.marker.enumDescriptions.ordered": "Use increasing numbers as ordered list marker.",
"config.preview.autoShowPreviewToSide.description": "Auto show preview to side.",
"config.print.absoluteImgPath.description": "Convert image path to absolute path.",
"config.print.imgToBase64.description": "Convert images to base64 when printing to HTML.",
"config.print.includeVscodeStylesheets": "Include VS Code's basic Markdown styles so that the exported HTML looks similar as inside VS Code.",
"config.print.onFileSave.description": "Print current document to HTML when file is saved.",
"config.print.theme": "Theme of the exported HTML. Only affects code blocks.",
"config.print.validateUrls.description": "Enable/disable URL validation when printing.",
"config.syntax.decorations.description": "Add syntax decorations in editors. (e.g. ~~strikethrough~~, `code span`)",
"config.syntax.decorationFileSizeLimit.description": "If a file is larger than this size (in byte/B), we won't attempt to render syntax decorations.",
"config.syntax.plainTheme.description": "Only take effect when `extension.syntax.decorations` is enabled.",
"config.tableFormatter.enabled.description": "Enable GitHub Flavored Markdown table formatter.",
"config.tableFormatter.normalizeIndentation.description": "Normalize table indentation to closest multiple of configured `tabSize`.",
"config.toc.downcaseLink.description": "Whether to **force** to downcase TOC links.",
"config.toc.levels.description": "Range of levels for table of contents. Use `x..y` for level `x` to `y`.",
"config.toc.omittedFromToc.description": "Lists of headings to omit by project file.\nExample:\n{ \"README.md\": [\"# Introduction\"] }",
"config.toc.orderedList.description": "Use ordered list, that is:\n1. ...\n2. ...",
"config.toc.plaintext.description": "Just plain text TOC, no links.",
"config.toc.slugifyMode.description": "The method to generate heading ID. This affects **links to headings** in **TOC**, **code completion**, and **printing**.",
"config.toc.unorderedList.marker.description": "Use `-`, `*`, or `+` in the table of contents (for **unordered** list).",
"config.toc.updateOnSave.description": "Auto update TOC on save.",
"showMe": "Show Me",
"dismiss": "Dismiss",
"noValidMarkdownFile": "No valid Markdown file",
Expand All @@ -62,4 +61,4 @@
"2.1.0 msg": "Markdown All in One v2.1.0! Paste URL as link, multi-cursor support, and more.",
"2.4.0 msg": "Markdown All in One v2.4.0! New command 'toggleList' and KaTeX macros support.",
"3.0.0 msg": "Markdown All in One v3.0.0! New command 'add section numbers' and better compatibility with other Markdown syntax extensions."
}
}
Loading

0 comments on commit 2a23bea

Please sign in to comment.