Skip to content

Instantly share code, notes, and snippets.

@TechplexEngineer
Created December 24, 2019 14:52
Show Gist options
  • Save TechplexEngineer/b38ba4d381bbd5072f07d868c9e324a1 to your computer and use it in GitHub Desktop.
Save TechplexEngineer/b38ba4d381bbd5072f07d868c9e324a1 to your computer and use it in GitHub Desktop.
parse rules from FRC game manual
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