Created
May 15, 2017 15:07
-
-
Save fhightower/2d0681db7576ff838ef6138041ba51f9 to your computer and use it in GitHub Desktop.
Increment :emphasize-lines: numbers
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
import os | |
import re | |
# read a file or define a variable that is a string here... | |
# this defines how much you would like to add to the values (can be a negative number) | |
delta = 2 | |
matches = re.findall(':emphasize-lines: (.*)', file_text) | |
# increment intervals appropriately | |
for match in matches: | |
emphasis_intervals = list() | |
for range_ in match.split(","): | |
new_nums = list() | |
for num in range_.split("-"): | |
new_nums.append(str(int(num) + delta)) | |
emphasis_intervals.append("-".join(new_nums)) | |
print("New intervals: {}".format(,".join(emphasis_intervals))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment