Hi,

I think you can use the parser to create your own shorthand notation, eg. 
to render ;;test;; as “curly quotes”, or you can probably also use a parser 
rule to replace straight quotes as well (altough I don't know if you risk 
quotes within code being replaced as well). See 
https://groups.google.com/g/tiddlywiki/c/IN46zvv4nCw

You can probably 
use $:/core/modules/parsers/wikiparser/rules/emphasis/superscript.js for 
inspiration (to "encapsule" something):

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;

// Parse the run including the terminator
var tree = this.parser.parseInlineRun(/\^\^/mg,{eatTerminator: true});

// Return the classed span
return [{
type: "element",
tag: "sup",
children: tree
}];
};

in combination with $:/core/modules/parsers/wikiparser/rules/dash.js (to 
replace the shorthand/straight quotes with a HTML entity):

exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /-{2,3}(?!-)/mg;
};

exports.parse = function() {
// Move past the match
this.parser.pos = this.matchRegExp.lastIndex;
var dash = this.match[0].length === 2 ? "–" : "—";
return [{
type: "entity",
entity: dash
}];
};


Best,
Anders
mandag 7. desember 2020 kl. 20:50:18 UTC+1 skrev coda coder:

> FWIW, I use AutoHotKey. I've wired up Ctrl+' and Ctrl+Shift+' to issue 
> curlies “like this”
>
> ;Pretty quotes
> ^':: SendInput “
> ^+':: SendInput ”
>
> On a US DT keyboard, at least, they're conveniently located. On UK 
> keyboards I know they're not so convenient. Android... no idea.
>
> On Sunday, December 6, 2020 at 8:01:51 PM UTC-6 Soren Bjornstad wrote:
>
>> I'm starting to get sick of using a four-button compose-key sequence to 
>> get “curly quotes” in my tiddlers. Has anyone thought about or tried 
>> integrating a library like smartquotes.js 
>> <https://github.com/kellym/smartquotes.js> into TiddlyWiki to 
>> automatically curl "straight quotes" in output? TiddlyWiki automatically 
>> upgrades hyphens to dashes, and if anything straight quotes are an even 
>> more egregious typographical mistake, so it feels like something TiddlyWiki 
>> should handle for me.
>>
>> I don't believe CodeMirror has any options related to upgrading the 
>> characters on insertion, but I do use CodeMirror so that would be an 
>> acceptable way too.
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ba25748e-e6e8-4c35-a4a6-487b91036dcbn%40googlegroups.com.

Reply via email to