-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #41 - Add auto_detection option to control hljs' language detection feature #43
Conversation
Add more test cases even with / without pre option
t.should("A Showdown extension for highlight the code blocks.", () => { | ||
// Now you can Highlight code blocks | ||
let html = converter.makeHtml(` | ||
const CODEBLOCK_WITH_LANGUAGE = ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's repetitively used, I extracted as constant.
\`\`\`` | ||
|
||
// After requiring the module, use it as extension | ||
const converter = new showdown.Converter({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since converter
is not changed, I used const
.
if (!lang && !auto_detection) { | ||
return wholeMatch | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Early return if auto_detection
is false
and there is no language information. This prevents redundant operations.
auto_detection: boolean | ||
} | ||
|
||
declare function showdownHighlight(options?: Partial<ShowdownHighlightOptions>): ShowdownExtension[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since its implementation has default parameter and default destructured value, it should be optional. Also Boolean
is not desirable for modern TypeScript declaration. #note
Related Issue
#41
Changes
auto_detection
option to enable/bypass hljs' language detectionauto_detection
istrue
, it works equivalent to previous versionauto_detection
isfalse
, originally matched HTML fragment will be returned without any changesclass="hljs"
at alltrue
to preserve compatibilityPartial
const
example
andDOCUMENTATION
.For more details, please checkout my self review.
Note
blah
related proper boilerplates in this repository. ButREAMDE
says no modification is allowed as it is generated fromblah
. If I just runblah --readme
and this will erase almost everything. We should fix this, or just add manually toREADME.