mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Get rid of the annoying //# style comments
They are used by the TiddlyWiki build tools to mark comments that should be stripped. In fact I think we should strip all comments
This commit is contained in:
parent
f33880f506
commit
a896ac0d56
@ -70,19 +70,19 @@ Formatter.enclosedTextHelper = function(w) {
|
||||
|
||||
Formatter.isExternalLink = function(link) {
|
||||
if(store.tiddlerExists(link) || store.isShadowTiddler(link)) {
|
||||
//# Definitely not an external link
|
||||
// Definitely not an external link
|
||||
return false;
|
||||
}
|
||||
var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
|
||||
if(urlRegExp.exec(link)) {
|
||||
//# Definitely an external link
|
||||
// Definitely an external link
|
||||
return true;
|
||||
}
|
||||
if(link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1 || link.indexOf("#")!=-1) {
|
||||
//# Link contains . / \ or # so is probably an external link
|
||||
// Link contains . / \ or # so is probably an external link
|
||||
return true;
|
||||
}
|
||||
//# Otherwise assume it is not an external link
|
||||
// Otherwise assume it is not an external link
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -445,7 +445,7 @@ Formatter.formatters = [
|
||||
{
|
||||
name: "image",
|
||||
match: "\\[[<>]?[Ii][Mm][Gg]\\[",
|
||||
//# [<] sequence below is to avoid lessThan-questionMark sequence so TiddlyWikis can be included in PHP files
|
||||
// [<] sequence below is to avoid lessThan-questionMark sequence so TiddlyWikis can be included in PHP files
|
||||
lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
|
||||
handler: function(w)
|
||||
{
|
||||
|
@ -6,11 +6,11 @@ var Tiddler = require("./Tiddler.js").Tiddler,
|
||||
utils = require("./Utils.js"),
|
||||
util = require("util");
|
||||
|
||||
//# Construct a wikifier object
|
||||
//# source - source string that's going to be wikified
|
||||
//# formatter - Formatter() object containing the list of formatters to be used
|
||||
//# highlightRegExp - regular expression of the text string to highlight
|
||||
//# tiddler - reference to the tiddler that's taken to be the container for this wikification
|
||||
// Construct a wikifier object
|
||||
// source - source string that's going to be wikified
|
||||
// formatter - Formatter() object containing the list of formatters to be used
|
||||
// highlightRegExp - regular expression of the text string to highlight
|
||||
// tiddler - reference to the tiddler that's taken to be the container for this wikification
|
||||
var Wikifier = function(source,formatter,highlightRegExp,tiddler)
|
||||
{
|
||||
this.source = source;
|
||||
@ -40,7 +40,7 @@ Wikifier.prototype.wikifyPlain = function()
|
||||
|
||||
Wikifier.prototype.subWikify = function(output,terminator)
|
||||
{
|
||||
//# Handle the terminated and unterminated cases separately, this speeds up wikifikation by about 30%
|
||||
// Handle the terminated and unterminated cases separately, this speeds up wikifikation by about 30%
|
||||
try {
|
||||
if(terminator)
|
||||
this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
|
||||
@ -53,10 +53,10 @@ Wikifier.prototype.subWikify = function(output,terminator)
|
||||
|
||||
Wikifier.prototype.subWikifyUnterm = function(output)
|
||||
{
|
||||
//# subWikify can be indirectly recursive, so we need to save the old output pointer
|
||||
// subWikify can be indirectly recursive, so we need to save the old output pointer
|
||||
var oldOutput = this.output;
|
||||
this.output = output;
|
||||
//# Get the first match
|
||||
// Get the first match
|
||||
this.formatter.formatterRegExp.lastIndex = this.nextMatch;
|
||||
var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
|
||||
while(formatterMatch) {
|
||||
@ -68,7 +68,7 @@ Wikifier.prototype.subWikifyUnterm = function(output)
|
||||
this.matchLength = formatterMatch[0].length;
|
||||
this.matchText = formatterMatch[0];
|
||||
this.nextMatch = this.formatter.formatterRegExp.lastIndex;
|
||||
//# Figure out which formatter matched and call its handler
|
||||
// Figure out which formatter matched and call its handler
|
||||
var t;
|
||||
for(t=1; t<formatterMatch.length; t++) {
|
||||
if(formatterMatch[t]) {
|
||||
@ -77,52 +77,52 @@ Wikifier.prototype.subWikifyUnterm = function(output)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//# Get the next match
|
||||
// Get the next match
|
||||
formatterMatch = this.formatter.formatterRegExp.exec(this.source);
|
||||
}
|
||||
//# Output any text after the last match
|
||||
// Output any text after the last match
|
||||
if(this.nextMatch < this.source.length) {
|
||||
this.outputText(this.output,this.nextMatch,this.source.length);
|
||||
this.nextMatch = this.source.length;
|
||||
}
|
||||
//# Restore the output pointer
|
||||
// Restore the output pointer
|
||||
this.output = oldOutput;
|
||||
};
|
||||
|
||||
Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
|
||||
{
|
||||
//# subWikify can be indirectly recursive, so we need to save the old output pointer
|
||||
// subWikify can be indirectly recursive, so we need to save the old output pointer
|
||||
var oldOutput = this.output;
|
||||
this.output = output;
|
||||
//# Get the first matches for the formatter and terminator RegExps
|
||||
// Get the first matches for the formatter and terminator RegExps
|
||||
terminatorRegExp.lastIndex = this.nextMatch;
|
||||
var terminatorMatch = terminatorRegExp.exec(this.source);
|
||||
this.formatter.formatterRegExp.lastIndex = this.nextMatch;
|
||||
var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
|
||||
while(terminatorMatch || formatterMatch) {
|
||||
//# Check for a terminator match before the next formatter match
|
||||
// Check for a terminator match before the next formatter match
|
||||
if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) {
|
||||
//# Output any text before the match
|
||||
// Output any text before the match
|
||||
if(terminatorMatch.index > this.nextMatch)
|
||||
this.outputText(this.output,this.nextMatch,terminatorMatch.index);
|
||||
//# Set the match parameters
|
||||
// Set the match parameters
|
||||
this.matchText = terminatorMatch[1];
|
||||
this.matchLength = terminatorMatch[1].length;
|
||||
this.matchStart = terminatorMatch.index;
|
||||
this.nextMatch = this.matchStart + this.matchLength;
|
||||
//# Restore the output pointer
|
||||
// Restore the output pointer
|
||||
this.output = oldOutput;
|
||||
return;
|
||||
}
|
||||
//# It must be a formatter match; output any text before the match
|
||||
// It must be a formatter match; output any text before the match
|
||||
if(formatterMatch.index > this.nextMatch)
|
||||
this.outputText(this.output,this.nextMatch,formatterMatch.index);
|
||||
//# Set the match parameters
|
||||
// Set the match parameters
|
||||
this.matchStart = formatterMatch.index;
|
||||
this.matchLength = formatterMatch[0].length;
|
||||
this.matchText = formatterMatch[0];
|
||||
this.nextMatch = this.formatter.formatterRegExp.lastIndex;
|
||||
//# Figure out which formatter matched and call its handler
|
||||
// Figure out which formatter matched and call its handler
|
||||
var t;
|
||||
for(t=1; t<formatterMatch.length; t++) {
|
||||
if(formatterMatch[t]) {
|
||||
@ -131,38 +131,38 @@ Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//# Get the next match
|
||||
// Get the next match
|
||||
terminatorRegExp.lastIndex = this.nextMatch;
|
||||
terminatorMatch = terminatorRegExp.exec(this.source);
|
||||
formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
|
||||
}
|
||||
//# Output any text after the last match
|
||||
// Output any text after the last match
|
||||
if(this.nextMatch < this.source.length) {
|
||||
this.outputText(this.output,this.nextMatch,this.source.length);
|
||||
this.nextMatch = this.source.length;
|
||||
}
|
||||
//# Restore the output pointer
|
||||
// Restore the output pointer
|
||||
this.output = oldOutput;
|
||||
};
|
||||
|
||||
Wikifier.prototype.outputText = function(place,startPos,endPos)
|
||||
{
|
||||
//# Check for highlights
|
||||
// Check for highlights
|
||||
while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) {
|
||||
//# Deal with any plain text before the highlight
|
||||
// Deal with any plain text before the highlight
|
||||
if(this.highlightMatch.index > startPos) {
|
||||
createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
|
||||
startPos = this.highlightMatch.index;
|
||||
}
|
||||
//# Deal with the highlight
|
||||
// Deal with the highlight
|
||||
var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
|
||||
createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
|
||||
startPos = highlightEnd;
|
||||
//# Nudge along to the next highlight if we're done with this one
|
||||
// Nudge along to the next highlight if we're done with this one
|
||||
if(startPos >= this.highlightRegExp.lastIndex)
|
||||
this.highlightMatch = this.highlightRegExp.exec(this.source);
|
||||
}
|
||||
//# Do the unhighlighted text left over
|
||||
// Do the unhighlighted text left over
|
||||
if(startPos < endPos) {
|
||||
createTiddlyText(place,this.source.substring(startPos,endPos));
|
||||
}
|
||||
@ -196,10 +196,10 @@ Wikifier.wikifyStatic = function(source,highlightRegExp,tiddler,format)
|
||||
return html;
|
||||
};
|
||||
|
||||
//# Wikify a string to plain text
|
||||
//# text - text to wikify
|
||||
//# limit - maximum number of characters to generate
|
||||
//# tiddler - optional reference to the tiddler containing this text
|
||||
// Wikify a string to plain text
|
||||
// text - text to wikify
|
||||
// limit - maximum number of characters to generate
|
||||
// tiddler - optional reference to the tiddler containing this text
|
||||
Wikifier.wikifyPlainText = function(text,limit,tiddler)
|
||||
{
|
||||
if(limit > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user