Request: Custom wikitext commands

88 views
Skip to first unread message

Mat

unread,
Dec 29, 2019, 10:14:57 AM12/29/19
to TiddlyWikiDev
Please help me phrase this into something suitable for a gh request - or, for that matter, enlighten me as to why I shouldn't:


Several requests over the years concern how some little thing should parse (term?) in some special way, equivalent to how e.g * and | become bullet lists and tables. (My own latest wish is for tab spaces). The purpose is to minimize distractions from your train-of-thoughts when authoring stuff.

I believe Jeremy has expressed positive comments about having a generic solution for this but I don't think there is a github issue about it nor do I think there has been any serious discussion about it. So, what is needed for this? As noted, it would possibly solve several made requests and it would overall be a powerful addition to the dynamism of TW and wikitext.

What would it take to implement this?

<:-)



@TiddlyTweeter

unread,
Dec 29, 2019, 10:45:57 AM12/29/19
to TiddlyWikiDev
Mat, FYI, this is something I mentioned quite often, but probably was misunderstood :-) ...

BJ provides more than one solution to parse in TW. Either through potential new content type parser sets, or through a pre-parser that runs before the main TW parsers.

IMO this is simply a pragmatic issue. 
The major barrier being that the main parsers are in JS which is not transparent to most of us. 
In other words, the barriers are more to do with how it would need coding than any intrinsic issue in TW. 
Nothing, as far as I can see, is stopping it.

For myself, I used BJ's raw regular expressions based pre-parser that is easy to use (for me being into regex) and serves my needs well to produce customised wikitext.

Ask if you need more info.
Best wishes, Josiah

Mat

unread,
Dec 29, 2019, 2:11:17 PM12/29/19
to TiddlyWikiDev
@TiddlyTweeter wrote:
The major barrier being that the main parsers are in JS which is not transparent to most of us. 

I'm thinking that since we do already have some strings that are converted (i.e we have wikitext) then the method applied for this conversion could perhaps be made general to use placeholders for input strings and what/how it outputs. The user could list all his custom wikitext in some kind of dictionary... specifying the custom input strings (start and end strings) and their "translation". It is also necessary with some security checks so that the user doesn't attempt to overwrite critical commands.

<:-)

TonyM

unread,
Dec 29, 2019, 5:44:43 PM12/29/19
to TiddlyWikiDev
Folks

I am keen to see more hackability I would like to extend wiki text to prefix a paragraph with period to wrap it in html p tags however when it comes to tabs the codemirror plugin supports tabs well.

Tony

@TiddlyTweeter

unread,
Dec 30, 2019, 8:15:55 AM12/30/19
to TiddlyWikiDev
Ciao Mat

Far be it from me to actually know the solution :-).

But I could imagine an additional JS "Custom Parser" that would let you pass through regular expressions that would recognise and render "Custom Markup."
This could be more than one. No reason why one Custom Parser might not do a few. 

I'm thinking of things like ...

On start of line (a <p>) = ".."
Renders as = "indent para 2rem left and right" (<p class="tw_custom_my-indent">)

The difficulty would be understanding "inter-actions" with extant wikitext and the parsing process. 

I doubt that could be core. But I think it should be well possible via plugin.

Best wishes
TT

@TiddlyTweeter

unread,
Dec 30, 2019, 9:07:03 AM12/30/19
to TiddlyWikiDev
TonyM wrote:

I am keen to see more hackability I would like to extend wiki text to prefix a paragraph with period to wrap it in html p tags however when it comes to tabs the codemirror plugin supports tabs well.


Ciao Tony

I'd say that the parser mechanism is very clean in TW.

It is well designed. It is eminently hackable.

I think the issue is largely about having some examples of how to create a new parser.

The parsers are in JS. Even though I don't understand JS I can see that it is the way to do it.
Parsing in TW uses regular expressions plus AST components to guard against conflicts between them, as well as cope with nesting situations.

In my last post to Mat I suggested that a "Custom Parser" might be one thing to ask for. 
That would be something like a JS parser that will take simple regex and apply it to "User Custom WikiText".

My two cents
TT



TonyM

unread,
Dec 31, 2019, 9:58:43 PM12/31/19
to TiddlyWikiDev
TT,

Agreed, I did try and hack the existing parser but failed. As Control Panel > Info > Advanced > parsing shows, there is a list of parse rules that can be toggled. I would like to see the ability to extend this and add out own, just as we can for example with the editor toolbar. In my case asking a leading period to wrap a paragraph in `<p></p>` or a version thereof would possibly be similar to other uses. In my case I dont need a generic solution but I would not be asking for this specific one if there was a general solution. I see three reasons to add minor additions to parsing;
  • To add a feature as I wish to get a useful markup addition
  • To add extended forms of markup such for someone doing a lot of document composition such as markup that throws a chapter etc...
  • To better handle text data from other sources 
The fact is the above can be handled with html in many cases but its nice to keep it minimal readable text.

I think the issue I face as a super user as opposed to a developer is how do I insert some custom parsing into the parsing process. I just want a little more hackability.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages