Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add convert script #180

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion SwiftCharts/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# SwiftCharts
![SwiftCharts](SwiftCharts.png)

Expand Down
31 changes: 31 additions & 0 deletions convertToJSON.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/bash

json='{"pages": ['
for d in */; do
# README.md が存在しないフォルダはスキップ
if [ ! -f "$d/README.md" ]; then
continue
fi
# title の # と空白を削除
title=$(head -n 1 "$d/README.md" | sed 's/# //g')
json+='{"title": "'$title'", "lines": ['
json+='"'$title'",'
json+='"[https://github.com/lifeistech/toybox/raw/main/'$title'/'$title'.gif]",'
while read line; do
if [[ $line =~ ^! ]]; then
continue
elif [[ $line =~ ^# ]]; then
# # をすべて削除し、行頭に [*、行末に ] を追加
line="[*${line//#/}] "
elif [[ $line =~ ^- ]]; then
# -をtabに置き換え
line=" ${line//-/} "
fi
json+='"'$line'",'
done < <(tail -n +2 "$d/README.md")
json+="]},"
done
json+="]}"
json=$(echo "$json" | sed -e 's/,]/]/g')

echo $json > scrapbox.json
2 changes: 1 addition & 1 deletion extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![extension](extension.gif)

## 概要
extensionは、"拡張する"という意味で、このコードを書くことでUILabelやIntなどの元から用意されているclassや自分で定義したclass, structに対して機能を拡張します。以下のようにextensionにwhereを付加した場合、型が条件を満たす場合のみ有効になる定義を追加することもできます。
extensionは、拡張するという意味で、このコードを書くことでUILabelやIntなどの元から用意されているclassや自分で定義したclass, structに対して機能を拡張します。以下のようにextensionにwhereを付加した場合、型が条件を満たす場合のみ有効になる定義を追加することもできます。
```
//要素がIntの配列の場合のみ有効になる定義
extension Array where Element == Int {
Expand Down