-
-
Save SamsungGalaxyPlayer/9a1aa08b59dd8c4a1e5cbb0e4ac0b973 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Usage: format-irclog.sh <file> | |
# 1. Append two spaces to the end of each line. | |
# 2. Remove all characters before last `<`, e.g. `<matterbridge> <sgp> foo` becomes `<sgp> foo`. | |
# 3. Remove lines containing `⇐` (parts). | |
# 4. Remove lines containing `→` (joins). | |
# 5. Escape the `*` character, e.g. `*foo*` becomes `\*foo\*`. | |
# 6. Escape the `<` character, e.g. `<3` becomes `\<3`. | |
# 7. Escape the `>` character, e.g. `1 > 0` becomes `1 \> 0`. | |
# 8. Embolden nick, e.g. `\<sgp\> foo` becomes `**\<sgp\>** foo`. | |
sed -E \ | |
-e 's/$/\ \ /' \ | |
-e 's/.*</</' \ | |
-e '/⇐/d' \ | |
-e '/→/d' \ | |
-e 's/\*/\\\*/g' \ | |
-e 's/_/\\_/g' \ | |
-e 's/</\\</g' \ | |
-e 's/>/\\>/g' \ | |
-e 's/\\<([^ ]+)\\>/\*\*\\<\1\\>\*\*/' \ | |
$1 |
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
#!/bin/sh | |
if [ "$#" -ne 5 ]; then | |
echo "Usage: $0 <YYYY> <MM> <DD> <CHAN> <TITLE>" >&2 | |
echo "Example: $0 2020 06 06 monero-community Community" >&2 | |
exit 1 | |
fi | |
AUTHOR=asymptotically | |
YYYY="$1" | |
MM="$2" | |
DD="$3" | |
CHAN="$4" | |
TITLE="$5" | |
FN="_posts/${YYYY}-${MM}-${DD}-${CHAN}-meeting.md" | |
REMOTE="https://monerologs.net/${CHAN}/${YYYY}${MM}${DD}/raw" | |
cat <<EOF>"$FN" | |
--- | |
layout: post | |
title: Logs for the ${TITLE} Meeting Held on ${YYYY}-${MM}-${DD} | |
author: ${AUTHOR} / TODO | |
--- | |
# Logs | |
EOF | |
curl -s "$REMOTE" | | |
sed -E \ | |
-e 's/$/\ \ /' \ | |
-e 's/.*</</' \ | |
-e 's/\*/\\\*/g' \ | |
-e 's/_/\\_/g' \ | |
-e 's/</\\</g' \ | |
-e 's/>/\\>/g' \ | |
-e 's/\\<([^ ]+)\\>/\*\*\\<\1\\>\*\*/' >>"$FN" | |
"$EDITOR" "$FN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment