Skip to content

Commit

Permalink
fix: fix html not rendered; fix broken multiline mode
Browse files Browse the repository at this point in the history
closes #23
  • Loading branch information
aidenlx committed Jan 12, 2022
1 parent 725e7f6 commit 92f46bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 40 deletions.
46 changes: 23 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@gerhobbelt/markdown-it-regexp": "^0.6.0-12",
"@release-it/bumper": "^2.0.0",
"@release-it/conventional-changelog": "^3.0.1",
"@rollup/plugin-commonjs": "^19.0.0",
"@gerhobbelt/markdown-it-regexp": "^0.6.0-15",
"@release-it/bumper": "^3.0.1",
"@release-it/conventional-changelog": "^4.1.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-typescript": "^8.2.1",
"@types/json-schema": "^7.0.7",
"@types/markdown-it": "^12.0.2",
"@types/node": "^15.12.4",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.0",
"@types/json-schema": "^7.0.9",
"@types/markdown-it": "^12.2.3",
"@types/node": "^17.0.8",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.29.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jsdoc": "^35.4.0",
"eslint-plugin-jsdoc": "^37.6.1",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"json": "^11.0.0",
"markdown-it": "^12.0.6",
"markdown-it": "^12.3.2",
"markdown-it-footnote": "^3.0.3",
"markdown-it-mark": "^3.0.1",
"markdown-it-multimd-table": "^4.1.0",
"obsidian": "^0.12.11",
"prettier": "^2.3.1",
"markdown-it-multimd-table": "^4.1.1",
"obsidian": "^0.13.11",
"prettier": "^2.5.1",
"punycode": "^2.1.1",
"release-it": "^14.10.0",
"rollup": "^2.52.2",
"release-it": "^14.12.1",
"rollup": "^2.63.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-import-css": "^2.0.1",
"tslib": "^2.3.0",
"typescript": "^4.3.4"
"rollup-plugin-import-css": "^3.0.2",
"tslib": "^2.3.1",
"typescript": "^4.5.4"
},
"release-it": {
"hooks": {
Expand Down
22 changes: 5 additions & 17 deletions src/tx-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ import {
TableExtendedSettings,
TableExtendedSettingTab,
} from "settings";

const sleep = async (ms: number) => {
return new Promise((resolve) => setTimeout(resolve, ms));
};
const INLINE_TYPE = "obsidian";

const wikiRegex =
/(?:(?<!\\)!)?\[\[([^\x00-\x1f|]+?)(?:\\?\|([^\x00-\x1f|]+?))?\]\]/;
export default class TableExtended extends Plugin {
settings: TableExtendedSettings = DEFAULT_SETTINGS;
async loadSettings() {
Expand All @@ -38,17 +30,13 @@ export default class TableExtended extends Plugin {
rowspan: true,
headerless: true,
});
this.mdit.renderer.rules[INLINE_TYPE] = (tokens, idx) => {
return tokens[idx].content;
};
/** keep only table required features, let obsidian handle the markdown inside cell */
this.mdit.block.ruler.enableOnly(["table", "paragraph", "reference"]);
this.mdit.inline.ruler.enableOnly([]);
}
mdit: MarkdownIt;
renderTable(raw: string) {
let blockTokens = this.mdit.parse(raw, {});
for (const t of blockTokens) {
t.type === "inline" && (t.type = INLINE_TYPE);
}
return this.mdit.renderer.render(blockTokens, this.mdit.options, {});
return this.mdit.render(raw);
}

processTable = (el: HTMLElement, ctx: MarkdownPostProcessorContext) => {
Expand Down Expand Up @@ -122,7 +110,7 @@ export default class TableExtended extends Plugin {
);

/**
* Fallback method, regular escape char will not take effect ()
* Fallback method, regular escape char will not take effect
*/
renderFromPara = (textEl: HTMLParagraphElement, blockEl: HTMLElement) => {
let elMap = new Map<string, Element>();
Expand Down

0 comments on commit 92f46bd

Please sign in to comment.