Last active
September 28, 2018 08:56
-
-
Save budparr/d929f3d662baa341fb843cd36e3dfe04 to your computer and use it in GitHub Desktop.
Terminal command to split a list of markdown items into separate documents. Given a "slug" value, the file will be named that. You could also change slug to title and create slugs/filenames from the title. You may also want to run your output through a markdown converter, like https://github.com/domchristie/to-markdown
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
csplit -k -n 3 export.txt '/^@@@/' {'999'}; for i in xx*; do sed -i '' 's/@@@/---/g' $i; done; for i in xx*; do mv $i `egrep -m1 -e 'slug:.*' $i | sed -e s/[^\]\[A-Za-z0-9~.,_{}\(\)\'\-\+]/-/g -e s/slug--//`.md; done |
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
--- | |
layout: empty | |
description: "this is a sample file for outputting content to be split with the CSPLIT command. Note the '@@@' at the top. | |
--- | |
{% assign data = site.data.events %} | |
{% for object in data %} | |
@@@<br /> | |
title:{% if object.title %} "{{ object.title }}"{% endif %}<br /> | |
published: true<br /> | |
category: event<br /> | |
start_at:{% if object.date %} {{ object.date | date: '%Y-%m-%d' }}T{% if object.start %}{{ object.start | date: '%k:%M' }}{% else %}00:00{% endif %}:00.000Z{% endif %}<br /> | |
allday:{% if object.allday %} true{% else %} false{% endif %}<br /> | |
venue:{% if object.venue %} "{{ object.venue }}"{% endif %}<br /> | |
address:{% if object.address %} "{{ object.address }}"{% endif %}<br /> | |
city-state:{% if object.city-state %} "{{ object.city-state }}"{% endif %}<br /> | |
zip:{% if object.zip %} "{{ object.zip }}"{% endif %}<br /> | |
website:{% if object.website %} "{{ object.website }}"{% endif %}<br /> | |
slug: {% if object.date %}{{ object.date | date: '%Y-%m-%d' }}{% if object.title %}-{{ object.title | slugify }}{% else %}-event{% endif %}{% endif %}<br /> | |
---<br /> | |
{% if object.summary %} | |
{{ object.summary }}<br /><br /> | |
{% endif %} | |
<br /> | |
{% endfor %} | |
<br /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment