-
Notifications
You must be signed in to change notification settings - Fork 129
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
1 parent
19e059a
commit 8a87a33
Showing
7 changed files
with
68 additions
and
20 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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import wtf from './src/index.js' | ||
console.log('start') | ||
|
||
let str = `before {{Vgrtbl|NA|1989-03-12|EU|August 16, 2008}} after | ||
let str = `before {{literal translation|a|b}} after | ||
` | ||
|
||
let doc = wtf(str) | ||
// const doc = await wtf.fetch('https://en.wikivoyage.org/wiki/Interstate_5') | ||
|
||
console.log(doc.template().json()) | ||
// console.log(doc.template().json()) | ||
console.log(doc.text()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import parse from '../../parse/toJSON/index.js' | ||
|
||
let shorthands = [ | ||
// {{HWV|251d}} - handel, bach | ||
['bwv', 'BWV'], | ||
['hwv', 'HWV'], | ||
['d.', 'D '], //Deutsch catalogue | ||
['aka', 'a.k.a. '], | ||
|
||
// date abbreviations | ||
['cf.', 'cf. '], | ||
['fl.', 'fl. '], | ||
['circa', 'c. '], | ||
['born in', 'b. '], | ||
['died-in', 'd. '], | ||
['married-in', 'm. '], | ||
] | ||
// create a function for each one | ||
let fns = shorthands.reduce((h, a) => { | ||
let [name, out] = a | ||
h[name] = (tmpl) => { | ||
let { first } = parse(tmpl, ['first']) | ||
if (first || first === 0) { | ||
return out + (first || '') | ||
} | ||
return out | ||
} | ||
return h | ||
}, {}) | ||
|
||
// return only the name of the template | ||
let justNames = [ | ||
'they', | ||
'them', | ||
'their', | ||
'theirs', | ||
'themself', | ||
'they are', | ||
'they were', | ||
'they have', | ||
'they do', | ||
'he or she', | ||
'him or her', | ||
'his or her', | ||
'his or hers', | ||
'he/she', | ||
'him/her', | ||
'his/her', | ||
] | ||
justNames.forEach((str) => { | ||
fns[str] = str | ||
}) | ||
|
||
export default fns |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
import hardcoded from './hardcoded.js' | ||
import easyInline from './easy-inline.js' | ||
import shorthand from './shorthands.js' | ||
import shorthand from './shorthand-link.js' | ||
import functions from './functions.js' | ||
import abbreviations from './abbreviations.js' | ||
import moreLangs from './languages.js' | ||
import flags from './flags.js' | ||
import table from './table-cell.js' | ||
|
||
export default Object.assign( | ||
{}, | ||
hardcoded, | ||
easyInline, | ||
shorthand, | ||
functions, | ||
moreLangs, | ||
flags, | ||
table, | ||
) | ||
export default Object.assign({}, hardcoded, easyInline, shorthand, functions, moreLangs, abbreviations, flags, table) |
File renamed without changes.