obsidianmd / obsidian-sample-plugin

2.61k stars 924 forks source link

Seeking example: plugin that extends the markdown syntax #19

Closed SimplGy closed 2 years ago

SimplGy commented 3 years ago

I'd like to extend the HyperMD / markdown parser, by matching patterns and adding css classnames if certain lines match a regex.

Is there an example that does this?

I can see how to style existing css classnames, but not how to add new classnames to the generated editor markup.

Thanks!

SimplGy commented 3 years ago

Possibly answering my own question here; would you say this is the right pattern to follow when adjusting the symbols added to decorate things in the editor panel?

https://github.com/aidenlx/table-extended/blob/master/src/tx-main.ts#L99

lishid commented 3 years ago

I don't think it would be easy to extend the parser at the moment. You might have to write an overlay mode and have it injected to the codemirror instances.

lishid commented 3 years ago

The link you provided hooks to the preview rendering rather than editor.

SimplGy commented 2 years ago

Maybe looking at https://github.com/SimplGy/obsidian-codemirror-options is the closest analogue. Noting that there's probably a pretty up-and-coming change the codemirror api level going to be used...