I don't know of any rules about where to post question

I think that question involving overriding core functionality provided by 
javascript can be answered here.

Firstly do you wish the extra markup to be applied globally, that is 
including the tiddlywiki UI or just to some tiddlers?

There are a number of ways of achiving this,

1) prepass the wikitext and add in the extra markup
2) override the parser rules 
3) the parser produces a AST, apply changes to the AST before the rendering
4) override the element widget.

I feel that 3 is the least hacky approch.

if you want non-global effect then 1 is simplest as the solution already 
exits.

If you want global effect 4 is the easiest

I would Monkey patch the tw5 parser (global effect) option 3:

The parses are loaded in the startup module 
$:/core/modules/startup/load-modules.js
by calling $tw.wiki.initParsers() which populates the array 
$tw.Wiki.parsers[].

the parser refrenced by $tw.Wiki.parsers["text/vnd.tddlywiki"] needs to be 
replaced with the new parser.
This is best achieved by including an extra startup module that runs after 
$:/core/modules/startup/load-modules.js 
with the simple code to replace this item in the array.

you can see an example of changing the AST in the markdown plugin: 
$:/plugins/tiddlywiki/markdown/wrapper.js, you 
can follow this pattern to produce the new parser.

all the best 

BJ

On Saturday, October 7, 2017 at 3:09:46 AM UTC+1, A X. wrote:
>
> I think I posted it in the wrong section:
>
> I want to change the way h? tags are rendered. Logic: If H? tag, then add 
> element after.  Do I have to write a widget or is there a much more simple 
> way to do this?
>
> Possible place: $:/core/modules/widgets/element.js
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/f47e32c2-a13d-44f1-9cd7-b578ac4e891e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to