Created
December 24, 2019 14:52
-
-
Save TechplexEngineer/b38ba4d381bbd5072f07d868c9e324a1 to your computer and use it in GitHub Desktop.
parse rules from FRC game manual
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
const ruleData = []; | |
$('p[class$="Rule"],p[class$="Rules"]').each((idx, rule) => { | |
const ruleObj = {}; | |
const ruleText = $(rule).find('span:first').text().match(/([A-Za-z])([0-9]+)/i); | |
if (_.isNull(ruleText)) { return true; } | |
ruleObj.section = ruleText[1]; | |
ruleObj.number = ruleText[2]; | |
let ruleLink = $(rule).find('a:first').attr('name'); | |
if (!ruleLink) { ruleLink = 'missing'; } | |
ruleObj.link = ruleLink; | |
ruleData.push(ruleObj); | |
}); | |
return ruleData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment