Hi again Soren,
It may not be the most elegant solution, but import the two attached
tiddlers (you may have to remove the .txt ending) to your tiddlywiki and
reload it. Then all you "test" will be replaced by “test” (the difference
is hard to spot with the default font though). Actually, you can choose any
character or string to replace the quotes with in $:/me/smartquote.css.
However, we add them by using ::before and ::after in css, so you will not
be able to select or copy the quotes themselves..
Best,
Anders
mandag 7. desember 2020 kl. 22:19:29 UTC+1 skrev Anjar:
> 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/4fc29de8-3aa6-4b2d-96bb-fd5c7f8a8c92n%40googlegroups.com.
created: 20201209220621567
modified: 20201209221722731
module-type: wikirule
tags:
title: $:/core/modules/parsers/wikiparser/rules/emphasis/quote.js
type: application/javascript
/*\
title: $:/core/modules/parsers/wikiparser/rules/emphasis/quote.js
type: application/javascript
module-type: wikirule
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "smartquote";
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;
// Parse the run including the terminator
var tree = this.parser.parseInlineRun(/\"/mg,{eatTerminator: true});
// Return the classed span
return [{
type: "element",
tag: "sq",
children: tree
}];
};
})();created: 20201209221723715
modified: 20201209222211930
tags: $:/tags/Stylesheet
title: $:/me/smartquote.css
type: text/css
sq::before {
content: "“";
}
sq::after {
content: "”";
}