diff --git a/README.md b/README.md index bd8040b..a7a30dc 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/grammar.js b/grammar.js index 9c6675e..e895657 100644 --- a/grammar.js +++ b/grammar.js @@ -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})}, @@ -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]) => diff --git a/grammar.ne b/grammar.ne index 0146465..99afd13 100644 --- a/grammar.ne +++ b/grammar.ne @@ -30,6 +30,7 @@ OTHER_TAG -> ( KEYWORD | CUSTOM | DOI | EDITION + | TITLE_ALT ) {% ([[d]]) => d %} @@ -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]) => diff --git a/index.js b/index.js index 62f7c76..194b336 100644 --- a/index.js +++ b/index.js @@ -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 ) diff --git a/lexer.js b/lexer.js index c92656b..d84c418 100644 --- a/lexer.js +++ b/lexer.js @@ -51,6 +51,7 @@ const lexer = , DO: /DO(?= - )/ , DP: /DP(?= - )/ , ET: /ET(?= - )/ + , J2: /J2(?= - )/ , KW: /KW(?= - )/ , PY: /PY(?= - )/ , RP: /RP(?= - )/ diff --git a/ris-parser.feature b/ris-parser.feature index fb2db55..ea425d0 100644 --- a/ris-parser.feature +++ b/ris-parser.feature @@ -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 |