This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from nnadeau/pandoc-filter
Added Pandoc filter
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ pytest-cov==2.5.1 | |
|
||
# misc | ||
GitPython==2.1.5 | ||
pandocfilters==1.2.4 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pandocfilters import toJSONFilter | ||
|
||
|
||
def strip_links(key, value, *_): | ||
# strip readme badges | ||
if key == 'Para': | ||
if value[0]['t'] == 'Link' and value[0]['c'][0][0]['t'] == 'Image': | ||
return [] | ||
|
||
# turn links to text | ||
if key == 'Link': | ||
return value[0] | ||
|
||
# strip raw html, logo, and ruled lines | ||
if key in ['RawBlock', 'HorizontalRule', 'Image']: | ||
return [] | ||
|
||
|
||
if __name__ == "__main__": | ||
toJSONFilter(strip_links) | ||
|
||
# debugging | ||
# with open('README.json') as f: | ||
# doc = json.load(f) | ||
# walk(doc, strip_links, '', '') |
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