Adding a Wikiparser rule for indentation

952 views
Skip to first unread message

Riz

unread,
Dec 14, 2016, 10:57:57 AM12/14/16
to TiddlyWiki


Hi,

I am trying to get TW5 to parse the symbol ^ as <span style="padding-left:20px;content:''"></span>

I tried to copy the other wikiparser rules like bold, heading etc and model something similar. All my attempts so far ended up in javascript errors.

Anyone? Thanks in advance.

Matthew Lauber

unread,
Dec 14, 2016, 11:19:57 AM12/14/16
to TiddlyWiki
A couple of questions: 
* Should this only work at the start of a line?  Or in the middle of the line too? 
* When should the span end?  (Closing ^ symbol, end of line?)
* Can you post what you've tried?  Best way would be exporting the tiddler as a .tid or json format, since some of the additional fields affect how this works.

Matt

Thomas Elmiger

unread,
Dec 14, 2016, 11:28:54 AM12/14/16
to TiddlyWiki
Hm, is this character not taken for superscript?

x^^2^^

What would you do with this span?

Good luck, Thomas

Rizwan Ishak

unread,
Dec 14, 2016, 11:34:17 AM12/14/16
to tiddl...@googlegroups.com

Start of the line would do just fine.
Span should end right after the opening Span. That is, the content between the Span should be null. I have specified the content using CSS, as you can see

I cloned the wikiparser for strike-through (and heading) and tried to change wherever the ~~ happens and finally the element: strike line.

I wouldn't mind any symbol on the keyboard to be parsed thus


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/loz80ybEoqo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ce606da1-f358-49af-ab82-5c27dfd2eb10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Elmiger

unread,
Dec 14, 2016, 11:59:36 AM12/14/16
to TiddlyWiki
I still don’t understand your exact use case.

Why don’t use a class and CSS?

http://www.w3schools.com/cssref/pr_text_text-indent.asp

Kind regards, Thomas

Riz

unread,
Dec 14, 2016, 12:09:32 PM12/14/16
to TiddlyWiki


I am trying to make the same easier. There are a lot of levels of intend and it is a pain to delcare a class and wrap it with CSS. Usually I keep a transparent list-style, which is also getting to impossible as I need those list-styles.

BJ

unread,
Dec 14, 2016, 1:57:55 PM12/14/16
to TiddlyWiki
how about a \ followed by three spaces

/*\
title: $:/core/modules/parsers/wikiparser/rules/indent.js
type: application/javascript
module-type: wikirule

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

exports.name = "indent";
exports.types = {inline: true};

exports.init = function(parser) {
	this.parser = parser;
	// Regexp to match
	this.matchRegExp = /\\   /mg;
};

exports.parse = function() {
	// Move past the match
	this.parser.pos = this.matchRegExp.lastIndex;
		var node = {
		type: "element",
		tag: "span",
		attributes: {
			"style": {type: "string", value: "padding-left:20px;content:''"}
		},
		children: []
	};
	return [node];
};

})();

Danielo Rodríguez

unread,
Dec 14, 2016, 2:05:15 PM12/14/16
to TiddlyWiki
I think that using an invisible character as part of a formatting rule is an horrible idea.

Just my two cents

PMario

unread,
Dec 14, 2016, 4:14:20 PM12/14/16
to TiddlyWiki
Hi,

IMO there is no need to create a new wikitext rule. There is already a rule that creates a <span> element: @@

Create a tiddler eg: myStyles and tag it $:/tags/Stylesheet

.x li,
li.x{
  list-style-type: none;
  padding-left: 0;
}

Now you can use the following syntax:

*.x indent 1
**.x indent 2

or

@@.x
* asdf asdf
** asdfasdfasdf
@@

-m


PMario

unread,
Dec 14, 2016, 4:16:50 PM12/14/16
to TiddlyWiki
On Wednesday, December 14, 2016 at 4:57:57 PM UTC+1, Riz wrote:
I am trying to get TW5 to parse the symbol ^ as <span style="padding-left:20px;content:''"></span>

IMO don't use px anymore, it doesn't work with our displays anymore. use em and its cousins instead!
-m

Sylvain Naudin

unread,
Dec 14, 2016, 4:34:03 PM12/14/16
to TiddlyWiki


Le mercredi 14 décembre 2016 22:14:20 UTC+1, PMario a écrit :

Now you can use the following syntax:

*.x indent 1
**.x indent 2


Oh ! Thank you for this cool tips ! Never think that class work for list like this !

Sylvain

Riz

unread,
Dec 14, 2016, 9:05:38 PM12/14/16
to TiddlyWiki
  @ BJ and PMario


Both of those methods works and opens an array of possibilites. Thanks you :-)

PMario

unread,
Dec 15, 2016, 2:19:00 PM12/15/16
to TiddlyWiki

PMario

unread,
Dec 15, 2016, 2:21:58 PM12/15/16
to TiddlyWiki
On Thursday, December 15, 2016 at 3:05:38 AM UTC+1, Riz wrote:
  @ BJ and PMario
Both of those methods works and opens an array of possibilites. Thanks you :-)

Yea,
TiddlyWiki offers a crazy amount of possibilities. ... (Way too many to be well documented ;)))
-m

Tobias Beer

unread,
Dec 16, 2016, 7:17:17 AM12/16/16
to TiddlyWiki
Hi Danielo,
 
I think that using an invisible character as part of a formatting rule is an horrible idea.

Just my two cents


I would disagree on this one,
To me it's both elegant and straight forward.

Actually, the number of spaces could correspond to the desired indenting level,
So you could define some system tiddler, globally defining the padding per level
as a combination of an amount and a unit (e.g. % or px or em or whatever)
and then compute how far you want to push a given line in
based on the number of blanks it starts with.

Best wishes,

Tobias.
 

Arlen Beiler

unread,
Dec 22, 2016, 7:22:06 AM12/22/16
to TiddlyWiki
Try also the MediaWiki famous ':'. It should work similar, but does not work exactly the same.

Never knew that before about the CSS classes!

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscribe@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages