Skip to content

Commit

Permalink
feat: add support for J2 tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Jun 26, 2020
1 parent f6e14e1 commit 17222db
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ ER -
| DB | db_provider | Database provider |
| DO | doi | DOI (Digital Object Identifier) |
| ET | edition | Edition |
| J2 | title_alt | Alternate title |
| KW | keyword | Keywords |
| PY | pub_year | Publication year |
| RP | reprint | Reprint status |
Expand Down
2 changes: 2 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function id(x) { return x[0]; }
{"name": "OTHER_TAG$subexpression$1", "symbols": ["CUSTOM"]},
{"name": "OTHER_TAG$subexpression$1", "symbols": ["DOI"]},
{"name": "OTHER_TAG$subexpression$1", "symbols": ["EDITION"]},
{"name": "OTHER_TAG$subexpression$1", "symbols": ["TITLE_ALT"]},
{"name": "OTHER_TAG", "symbols": ["OTHER_TAG$subexpression$1"], "postprocess": ([[d]]) => d},
{"name": "ABSTRACT", "symbols": [(lexer.has("AB") ? {type: "AB"} : AB), (lexer.has("SEP") ? {type: "SEP"} : SEP), (lexer.has("CONTENT") ? {type: "CONTENT"} : CONTENT), "__"], "postprocess": ([,,{value}]) => ({key: 'abstract' , value})},
{"name": "AUTHOR_ADDR", "symbols": [(lexer.has("AD") ? {type: "AD"} : AD), (lexer.has("SEP") ? {type: "SEP"} : SEP), (lexer.has("CONTENT") ? {type: "CONTENT"} : CONTENT), "__"], "postprocess": ([,,{value}]) => ({key: 'author_address', value})},
Expand All @@ -49,6 +50,7 @@ function id(x) { return x[0]; }
{"name": "DB_PROV", "symbols": [(lexer.has("DP") ? {type: "DP"} : DP), (lexer.has("SEP") ? {type: "SEP"} : SEP), (lexer.has("CONTENT") ? {type: "CONTENT"} : CONTENT), "__"], "postprocess": ([,,{value}]) => ({key: 'db_provider' , value})},
{"name": "DOI", "symbols": [(lexer.has("DO") ? {type: "DO"} : DO), (lexer.has("SEP") ? {type: "SEP"} : SEP), (lexer.has("CONTENT") ? {type: "CONTENT"} : CONTENT), "__"], "postprocess": ([,,{value}]) => ({key: 'doi' , value})},
{"name": "EDITION", "symbols": [(lexer.has("ET") ? {type: "ET"} : ET), (lexer.has("SEP") ? {type: "SEP"} : SEP), (lexer.has("CONTENT") ? {type: "CONTENT"} : CONTENT), "__"], "postprocess": ([,,{value}]) => ({key: 'edition' , value})},
{"name": "TITLE_ALT", "symbols": [(lexer.has("J2") ? {type: "J2"} : J2), (lexer.has("SEP") ? {type: "SEP"} : SEP), (lexer.has("CONTENT") ? {type: "CONTENT"} : CONTENT), "__"], "postprocess": ([,,{value}]) => ({key: 'title_alt' , value})},
{"name": "KEYWORD$ebnf$1", "symbols": ["LINE"]},
{"name": "KEYWORD$ebnf$1", "symbols": ["KEYWORD$ebnf$1", "LINE"], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "KEYWORD", "symbols": [(lexer.has("KW") ? {type: "KW"} : KW), (lexer.has("SEP") ? {type: "SEP"} : SEP), "KEYWORD$ebnf$1"], "postprocess": ([,,lines]) =>
Expand Down
2 changes: 2 additions & 0 deletions grammar.ne
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OTHER_TAG -> ( KEYWORD
| CUSTOM
| DOI
| EDITION
| TITLE_ALT
)
{% ([[d]]) => d %}

Expand All @@ -45,6 +46,7 @@ DB_NAME -> %DB %SEP %CONTENT __ {% ([,,{value}]) => ({key: 'db_name'
DB_PROV -> %DP %SEP %CONTENT __ {% ([,,{value}]) => ({key: 'db_provider' , value}) %}
DOI -> %DO %SEP %CONTENT __ {% ([,,{value}]) => ({key: 'doi' , value}) %}
EDITION -> %ET %SEP %CONTENT __ {% ([,,{value}]) => ({key: 'edition' , value}) %}
TITLE_ALT -> %J2 %SEP %CONTENT __ {% ([,,{value}]) => ({key: 'title_alt' , value}) %}

KEYWORD -> %KW %SEP LINE:+
{% ([,,lines]) =>
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const to_record =
, 'edition' , add
, 'pub_year' , add
, 'pub_loc' , add
, 'title_alt' , add
, 'date' , (acc, {value}) =>
( acc.date = zip(['year', 'month', 'day', 'info'])(value)
, acc )
Expand Down
1 change: 1 addition & 0 deletions lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const lexer =
, DO: /DO(?= - )/
, DP: /DP(?= - )/
, ET: /ET(?= - )/
, J2: /J2(?= - )/
, KW: /KW(?= - )/
, PY: /PY(?= - )/
, RP: /RP(?= - )/
Expand Down
1 change: 1 addition & 0 deletions ris-parser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Scenario Outline: Other tags
| DP | dbprovidedby1 | db_provider | dbprovidedby1 |
| DO | 10.1177/0003122411414817 | doi | 10.1177/0003122411414817 |
| ET | 4th Ed. | edition | 4th Ed. |
| J2 | R2D2 | title_alt | R2D2 |
| RP | IN FILE | reprint | IN FILE |
| RP | NOT IN FILE | reprint | NOT IN FILE |
| RP | ON REQUEST (06/26/2020) | reprint | ON REQUEST |
Expand Down

0 comments on commit 17222db

Please sign in to comment.