Last active
January 27, 2022 01:55
-
-
Save ryancatalani/a638c2bbbbec5c9d375e1c551712e0f8 to your computer and use it in GitHub Desktop.
Automatically add links to bill numbers (Hawaiʻi state legislature)
This file contains hidden or 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
function linkBills(text, newWindow=true) { | |
const year = 2022; | |
const regex = /([HS]C?[BR]) ?(\d{1,4})/g; | |
const target = newWindow ? "target='_blank'" : ""; | |
return text.replaceAll(regex, `<a href="https://www.capitol.hawaii.gov/measure_indiv.aspx?billtype=$1&billnumber=$2&year=${year}" ${target}>$1 $2</a>`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment