Biblography bib File Reader Parser Validator Essentially it goes through the steps of writing a relatively robust bib file parser for all your citations which can contain everything from author and title details through to additional attributes like citation count or abstract notes The first couple of versions show a basic tokenizer concept which is fine but has issues the final couple of versions add extra details and create a relatively robust parser Good if you want to create a bib file with lots of data then you can parse it to generate graphs plots or view extra statistics also used for your articles latex file etc var txt inproceedings Carrel2005 n title Algorithm for near optimal autonomous resource management n author Carrel ndrew and Palmer Phil n notes nonote n booktitle 8th International Symposium on Artificial Intelligence n Robotics and Automation in Space n year 2005 n blahblah error n function tokenizer text this index 0 this length text length this text text this scope 0 this getNextToken function if this index this length 1 return null let token while this index this length let c this text charAt this index this index switch c case return token case if this scope 1 break return token case this scope if this scope 1 continue return token case this scope if this scope 1 return token continue case return token case n continue case if this scope 1 continue token c return token return this end tokenizer function parseBibTex text let bibs let curbib let t new tokenizer text while true let token t getNextToken if token null break switch token case let name t getNextToken console log name break default console log unknown token token break end switch end while end parseBibTex console log ready console log parseBibTex txt var txt inproceedings Carrel2005 n title Algorithm for near optimal autonomous resource management n author Carrel ndrew and Palmer Phil n notes nonote n booktitle 8th International Symposium on Artificial Intelligence n Robotics and Automation in Space n year 2005 n blahblah error n function tokenizer text this index 0 this length text length this text text this getNextToken function if this index this length 1 return null while this index this length let c this text charAt this index this index switch c case return case return case return case n continue skip new lines case continue skip spaces case let token let scope 0 while true c this text charAt this index if c scope if c if scope 0 this index break scope token c this index return token break default let token c while true c this text charAt this index if includes c break token c this index return token return c return null return this end tokenizer function parseBibTex text let bibs let curbib let t new tokenizer text console log t getNextToken console log t getNextToken type let body t getNextToken console log body console log let b new tokenizer body console log b getNextToken bibname console log b getNextToken console log console log b getNextToken itemname console log b getNextToken console log b getNextToken string console log b getNextToken console log console log b getNextToken itemname console log b getNextToken console log b getNextToken string console log b getNextToken while true let token t getNextToken if token null break switch token case let name t getNextToken console log name break default console log unknown token token break end switch end while end parseBibTex console log ready console log parseBibTex txt var txt inproceedings Carrel2005 n title Algorithm for near optimal autonomous resource management n author Carrel ndrew and Palmer Phil n notes nonote n booktitle 8th International Symposium on Artificial Intelligence n Robotics and Automation in Space n year 2005 n blahblah error n function tokenizer text this index 0 this length text length this text text this getNextToken function if this index this length 1 return null while this index this length let c this text charAt this index this index switch c case return case return case return case n continue skip new lines case continue skip spaces case let token let scope 0 while true c this text charAt this index if c scope if c if scope 0 this index break scope token c this index return token break default let token c while true c this text charAt this index if includes c break token c this index return token return c return null return this end tokenizer function parseBibTex text let allbibs let t new tokenizer text while true let token t getNextToken if token null break if token console log expecting token t getNextToken bib item type journal proceeding let body t getNextToken body of the bib item let b new tokenizer body let bibname b getNextToken token b getNextToken if token console log expecting if bibname in allbibs console log error multiple bibs with same name allbibs bibname while true token b getNextToken if token null break let itemname token token b getNextToken if token console log expecting let itemvalue b getNextToken token b getNextToken or null allbibs bibname itemname itemvalue return allbibs end parseBibTex console log ready let bibs parseBibTex txt console log bibs bibs function tokenizer text this index 0 this length text length this text text this getNextToken function if this index this length 1 return null while this index this length let c this text charAt this index this index switch c case return case return case return case n continue skip new lines case continue skip spaces case let token let scope 0 while true c this text charAt this index if c scope if c if scope 0 this index break scope token c this index return token break todo add in a case for nested quotes should be the same as the curly bracket version above default let token c while true c this text charAt this index if includes c break token c this index return token return c return null return this end tokenizer function parseBibTex text let allbibs let t new tokenizer text while true let token t getNextToken if token null break if token console log expecting token t getNextToken bib item type journal proceeding let body t getNextToken body of the bib item let b new tokenizer body let bibname b getNextToken token b getNextToken if token console log expecting if bibname in allbibs console log error multiple bibs with same name allbibs bibname while true token b getNextToken if token null break let itemname token toLowerCase token b getNextToken if token console log expecting let itemvalue b getNextToken token b getNextToken or null allbibs bibname itemname itemvalue return allbibs end parseBibTex console log ready let res await fetch https notebook xbdev net var scripts example bib let txt await res text let bibs parseBibTex txt console log number of bib entries Object keys bibs length print out the title for each bib entry for let key in bibs let bib bibs key console log title bib title at this point it s very easy to skim over any bibs even add extra attributes to the bib file e g abstract number of citations bools etc
year 2005 n blahblah error n function tokenizer text this index 0 this length text length this text text this getNextToken function if this index this length 1 return null while this index this length let c this text charAt this index this index switch c case return case return case return case n continue skip new lines case continue skip spaces case let token let scope 0 while true c this text charAt this index if c scope if c if scope 0 this index break scope token c this index return token break default let token c while true c this text charAt this index if includes c break token c this index return token return c return null return this end tokenizer function parseBibTex text let allbibs let t new tokenizer text while true let token t getNextToken if token null break if token console log expecting token t getNextToken bib item type journal proceeding let body t getNextToken body of the bib item let b new tokenizer body let bibname b getNextToken token b getNextToken if token console log expecting if bibname in allbibs console log error multiple bibs with same name allbibs bibname while true token b getNextToken if token null break let itemname token token b getNextToken if token console log expecting let itemvalue b getNextToken token b getNextToken or null allbibs bibname itemname itemvalue return allbibs end parseBibTex console log ready let bibs parseBibTex txt console log bibs bibs function tokenizer text this index 0 this length text length this text text this getNextToken function if this index this length 1 return null while this index this length let c this text charAt this index this index switch c case return case return case return case n continue skip new lines case continue skip spaces case let token let scope 0 while true c this text charAt this index if c scope if c if scope 0 this index break scope token c this index return token break todo add in a case for nested quotes should be the same as the curly bracket version above default let token c while true c this text charAt this index if includes c break token c this index return token return c return null return this end tokenizer function parseBibTex text let allbibs let t new tokenizer text while true let token t getNextToken if token null break if token console log expecting token t getNextToken bib item type journal proceeding let body t getNextToken body of the bib item let b new tokenizer body let bibname b getNextToken token b getNextToken if token console log expecting if bibname in allbibs console log error multiple bibs with same name allbibs bibname while true token b getNextToken if token null break let itemname token toLowerCase token b getNextToken if token console log expecting let itemvalue b getNextToken token b getNextToken or null allbibs bibname itemname itemvalue return allbibs end parseBibTex console log ready let res await fetch https notebook xbdev net var scripts example bib let txt await res text let bibs parseBibTex txt console log number of bib entries Object keys bibs length print out the title for each bib entry for let key in bibs let bib bibs key console log title bib title at this point it s very easy to skim over any bibs even add extra attributes to the bib file e g abstract number of citations bools etc