Skip to content

Commit

Permalink
Added latex \text{} command
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaRedozubova committed Sep 11, 2023
1 parent 0fca41f commit 0b4f8ef
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion es5/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion es5/index.js

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion lib/markdown/mdPluginText.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/markdown/mdPluginText.js.map

Large diffs are not rendered by default.

23 changes: 21 additions & 2 deletions src/markdown/mdPluginText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ const textTypes: RuleInline = (state) => {
}
const match = state.src
.slice(++startPos)
.match(/^(?:textit|textbf|texttt)/); // eslint-disable-line
.match(/^(?:textit|textbf|texttt|text)/); // eslint-disable-line

if (!match) {
return false;
Expand All @@ -847,6 +847,9 @@ const textTypes: RuleInline = (state) => {
break;
case "texttt":
type = "texttt";
break;
case "text":
type = "text_latex";
break;
default:
break;
Expand Down Expand Up @@ -1238,6 +1241,13 @@ const renderItalicText = (tokens, idx, options, env, slf) => {
return content;
};

const renderTextLatex = (tokens, idx, options, env, slf) => {
const token = tokens[idx];
const content = renderInlineContent(token, options, env, slf);

return content;
};

const renderCodeInlineOpen = (tokens, idx, options, env, slf) => {
const token = tokens[idx];
return '<code' + slf.renderAttrs(token) + '>';
Expand Down Expand Up @@ -1287,6 +1297,10 @@ const mappingTextStyles = {
texttt_open: "texttt_open",
texttt_close: "texttt_close",

text_latex: "TextLatex",
text_latex_open: "TextLatexOpen",
text_latex_close: "TextLatexClose",

underline: "underline",
underline_open: "underline_open",
underline_close: "underline_close",
Expand Down Expand Up @@ -1349,7 +1363,12 @@ export default () => {
case "textit_open":
return '<em>';
case "textit_close":
return '</em>';
return '</em>';
case "text_latex_open":
case "text_latex_close":
return '';
case "text_latex":
return renderTextLatex(tokens, idx, options, env, slf);
case "underline":
return renderUnderlineText(tokens, idx, options, env, slf);
case "underline_open":
Expand Down

0 comments on commit 0b4f8ef

Please sign in to comment.