inline code syntax highlighting: marpit custom engine + css
This commit is contained in:
21
marp.config.js
Normal file
21
marp.config.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const { Marp } = require('@marp-team/marp-core');
|
||||||
|
const hljs = require('highlight.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
engine: (opts) => {
|
||||||
|
const marp = new Marp(opts);
|
||||||
|
const md = marp.markdown;
|
||||||
|
const defaultInline = md.renderer.rules.code_inline
|
||||||
|
|| ((tokens, idx, options, env, self) => `<code>${md.utils.escapeHtml(tokens[idx].content)}</code>`);
|
||||||
|
md.renderer.rules.code_inline = (tokens, idx, options, env, self) => {
|
||||||
|
const content = tokens[idx].content;
|
||||||
|
try {
|
||||||
|
const highlighted = hljs.highlight(content, { language: 'html', ignoreIllegals: true }).value;
|
||||||
|
return `<code class="hljs language-html">${highlighted}</code>`;
|
||||||
|
} catch (e) {
|
||||||
|
return defaultInline(tokens, idx, options, env, self);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return marp;
|
||||||
|
}
|
||||||
|
};
|
||||||
1930
package-lock.json
generated
Normal file
1930
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -13,11 +13,18 @@
|
|||||||
"deploy": "make deploy",
|
"deploy": "make deploy",
|
||||||
"test": "echo \"No tests specified\" && exit 0"
|
"test": "echo \"No tests specified\" && exit 0"
|
||||||
},
|
},
|
||||||
"keywords": ["marp", "slides", "hdm", "lectures"],
|
"keywords": [
|
||||||
|
"marp",
|
||||||
|
"slides",
|
||||||
|
"hdm",
|
||||||
|
"lectures"
|
||||||
|
],
|
||||||
"author": "Michael Czechowski <mail@librete.ch>",
|
"author": "Michael Czechowski <mail@librete.ch>",
|
||||||
"license": "CC-BY-SA-4.0",
|
"license": "CC-BY-SA-4.0",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@marp-team/marp-cli": "^4.2.3"
|
"@marp-team/marp-cli": "^4.2.3",
|
||||||
|
"@marp-team/marp-core": "^4.3.0",
|
||||||
|
"highlight.js": "^11.11.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,4 +41,4 @@ echo -e " ${BLUE}http://localhost:$DEV_PORT${NC}"
|
|||||||
echo -e " ${BLUE}$SERVE_DIR/${NC}"
|
echo -e " ${BLUE}$SERVE_DIR/${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
PORT=$DEV_PORT exec npx @marp-team/marp-cli --server "$SERVE_DIR/"
|
PORT=$DEV_PORT exec npx @marp-team/marp-cli -c marp.config.js --server "$SERVE_DIR/"
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ pre code {
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
code {
|
code {
|
||||||
background: #1a1a2e;
|
background: #0f0f23;
|
||||||
color: #d63384;
|
|
||||||
padding: 0.15em 0.4em;
|
padding: 0.15em 0.4em;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
|
||||||
}
|
}
|
||||||
|
section code:not(.hljs) { color: #d63384 !important; }
|
||||||
|
section code.hljs { color: #f8f8f8 !important; }
|
||||||
a {
|
a {
|
||||||
color: var(--color-highlight);
|
color: var(--color-highlight);
|
||||||
}
|
}
|
||||||
@@ -1281,8 +1283,7 @@ Steuert die Vorschau beim Teilen auf Mastodon, LinkedIn, Signal, MS Teams, Slack
|
|||||||

|

|
||||||
|
|
||||||
```html
|
```html
|
||||||
<label>Geburtsdatum</label>
|
Geburtsdatum <input type="date" />
|
||||||
<input type="date" />
|
|
||||||
```
|
```
|
||||||
|
|
||||||
| Teil | Bezeichnung |
|
| Teil | Bezeichnung |
|
||||||
|
|||||||
Reference in New Issue
Block a user