-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
key: ib-filter | ||
name: Sample filter | ||
category: filters | ||
instructions: This is a sample filter. | ||
filter: > | ||
var inlineRegex2 = /\\\(((?:.|\n)+?)\\\)/mgi; | ||
var displayRegex2 = /\\\[((?:.|\n)+?)\\\]/mgi; | ||
var divDisplaynotranslateRegex = /<\s*div\s+class\s*=\s*\"\s*notranslate\s*\"\s*>(\s*\\\[((?:.|\n)+?)\\\]\s*)<\/\s*div\s*>/mgi; | ||
var spanInlinenotranslateRegex = /<\s*span\s+class\s*=\s*\"\s*notranslate\s*\"\s*>(\s*\\\(((?:.|\n)+?)\\\)\s*)<\/\s*span\s*>/mgi; | ||
var verifiedRegex = /<!--filtre notranslate aplicat (.*?)-->/mgi; | ||
var randomkey = function() { | ||
return 'k'+Math.random().toString(32).substring(2); | ||
}; | ||
var formulesOk = 0; | ||
var formulesPendents = 0; | ||
var mapaFormulas = {}; | ||
var code = text.replace(divDisplaynotranslateRegex, function ($0, $1, $2, $3) { | ||
var key = randomkey() + formulesOk; | ||
mapaFormulas[key] = $0; | ||
formulesOk++; | ||
return " [[["+key+"]]] "; | ||
}); | ||
code = code.replace(spanInlinenotranslateRegex, function ($0, $1, $2, $3) { | ||
var key = randomkey() + formulesOk; | ||
mapaFormulas[key] = $0; | ||
formulesOk++; | ||
return " [[["+key+"]]] "; | ||
}); | ||
code = code.replace(inlineRegex2, function ($0, $1, $2, $3) { | ||
formulesPendents++; | ||
return "<span class=\"notranslate\"> \\(" + $1 + "\\)</span>"; | ||
}); | ||
code = code.replace(displayRegex2, function ($0, $1, $2, $3) { | ||
formulesPendents++; | ||
return " <div class=\"notranslate\"> \\[" + $1 + "\\] </div>"; | ||
}); | ||
var claus = Object.keys(mapaFormulas); | ||
for(var i=0; i<claus.length; i++) { | ||
var key = claus[i]; | ||
code = code.replace("[[["+key+"]]]", mapaFormulas[key]); | ||
} | ||
var total = formulesPendents + formulesOk; | ||
var msg_stats = "S'han detectat " + total + " fòrmules i s'han corregit "+formulesPendents; | ||
if(formulesPendents===0){ | ||
code=null; | ||
} | ||
return [code, msg_stats]; | ||
author: Josep Mulet Pol <pep.mulet@gmail.com> | ||
version: 2024.12.01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters