You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-27 23:28:38 +02:00
Syntax highlighting on webview
This commit is contained in:
ElectronClient/app
gui
highlight
CHANGES.mdLICENSEREADME.mdREADME.ru.mdhighlight.pack.js
note-content.htmlstyles
agate.cssandroidstudio.cssarduino-light.cssarta.cssascetic.cssatelier-cave-dark.cssatelier-cave-light.cssatelier-dune-dark.cssatelier-dune-light.cssatelier-estuary-dark.cssatelier-estuary-light.cssatelier-forest-dark.cssatelier-forest-light.cssatelier-heath-dark.cssatelier-heath-light.cssatelier-lakeside-dark.cssatelier-lakeside-light.cssatelier-plateau-dark.cssatelier-plateau-light.cssatelier-savanna-dark.cssatelier-savanna-light.cssatelier-seaside-dark.cssatelier-seaside-light.cssatelier-sulphurpool-dark.cssatelier-sulphurpool-light.cssatom-one-dark.cssatom-one-light.cssbrown-paper.cssbrown-papersq.pngcodepen-embed.csscolor-brewer.cssdarcula.cssdark.cssdarkula.cssdefault.cssdocco.cssdracula.cssfar.cssfoundation.cssgithub-gist.cssgithub.cssgooglecode.cssgrayscale.cssgruvbox-dark.cssgruvbox-light.csshopscotch.csshybrid.cssidea.cssir-black.csskimbie.dark.csskimbie.light.cssmagula.cssmono-blue.cssmonokai-sublime.cssmonokai.cssobsidian.cssocean.cssparaiso-dark.cssparaiso-light.csspojoaque.csspojoaque.jpgpurebasic.cssqtcreator_dark.cssqtcreator_light.cssrailscasts.cssrainbow.cssrouteros.cssschool-book.cssschool-book.pngsolarized-dark.csssolarized-light.csssunburst.csstomorrow-night-blue.csstomorrow-night-bright.csstomorrow-night-eighties.csstomorrow-night.csstomorrow.cssvs.cssvs2015.cssxcode.cssxt256.csszenburn.css
ReactNativeClient/lib
@ -146,6 +146,7 @@ class MdToHtml {
|
||||
let openTag = null;
|
||||
let closeTag = null;
|
||||
let attrs = t.attrs ? t.attrs : [];
|
||||
const isCodeBlock = tag === 'code' && t.block;
|
||||
|
||||
if (t.map) attrs.push(['data-map', t.map.join(':')]);
|
||||
|
||||
@ -157,17 +158,25 @@ class MdToHtml {
|
||||
openTag = tag;
|
||||
} else if (t.type === 'link_open') {
|
||||
openTag = 'a';
|
||||
} else if (isCodeBlock) {
|
||||
openTag = 'pre';
|
||||
}
|
||||
|
||||
if (openTag) {
|
||||
if (openTag === 'a') {
|
||||
output.push(this.renderOpenLink_(attrs, options));
|
||||
} else {
|
||||
const attrsHtml = attrs ? this.renderAttrs_(attrs) : '';
|
||||
const attrsHtml = this.renderAttrs_(attrs);
|
||||
output.push('<' + openTag + (attrsHtml ? ' ' + attrsHtml : '') + '>');
|
||||
}
|
||||
}
|
||||
|
||||
if (isCodeBlock) {
|
||||
const codeAttrs = ['code'];
|
||||
if (t.info) codeAttrs.push(t.info); // t.info contains the language when the token is a codeblock
|
||||
output.push('<code class="' + codeAttrs.join(' ') + '">');
|
||||
}
|
||||
|
||||
if (t.type === 'image') {
|
||||
if (t.content) attrs.push(['title', t.content]);
|
||||
output.push(this.renderImage_(attrs, options));
|
||||
@ -186,8 +195,12 @@ class MdToHtml {
|
||||
closeTag = 'a';
|
||||
} else if (tag && t.type.indexOf('inline') >= 0) {
|
||||
closeTag = openTag;
|
||||
} else if (isCodeBlock) {
|
||||
closeTag = openTag;
|
||||
}
|
||||
|
||||
if (isCodeBlock) output.push('</code>');
|
||||
|
||||
if (closeTag) {
|
||||
if (closeTag === 'a') {
|
||||
output.push(this.renderCloseLink_(attrs, options));
|
||||
@ -302,6 +315,7 @@ class MdToHtml {
|
||||
const styleHtml = '<style>' + normalizeCss + "\n" + css + '</style>';
|
||||
|
||||
const output = styleHtml + renderedBody;
|
||||
|
||||
this.cachedContent_ = output;
|
||||
this.cachedContentKey_ = cacheKey;
|
||||
return this.cachedContent_;
|
||||
|
Reference in New Issue
Block a user