-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforum-to-blog.sh
executable file
·67 lines (56 loc) · 2.01 KB
/
forum-to-blog.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#
# Copyright (c) 2024 Roberto Michán Sánchez (Roboron) <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Simple program to convert a BBCode post to an HTML post
# Usually used to convert a post from the International Simutrans Forum / Steam News to a Simutrans Blog post
# It takes a file where the post is written in bbcode, and convert that very same file to html
# TODO: revisar si el width de las imágenes realmente es necesario...
FILE=$1
# convert links
sed -i 's/\[url="/<a href="/g' $FILE
sed -i 's/\[url=/<a href="/g' $FILE
sed -i 's/\[\/url\]/<\/a>/g' $FILE
# convert images
sed -i 's/\[img\]/<img src="/g' $FILE
sed -i 's/\[\/img\]/" width="800">/g' $FILE
# convert lists
sed -i 's/\[list\]/<ul>/g' $FILE
sed -i 's/\[\/list\]/<\/ul>/g' $FILE
sed -i 's/\[\/olist\]/<\/ol>/g' $FILE
sed -i 's/\[olist\]/<ol>/g' $FILE
sed -i 's/\[\*\]/<li>/g' $FILE
#sed -i 's/\[\/list\]/</ul>/g' $FILE
# convert headers
sed -i 's/\[h1]/<h1>/g' $FILE
sed -i 's/\[\/h1\]/<\/h1>/g' $FILE
sed -i 's/\[h2]/<h2>/g' $FILE
sed -i 's/\[\/h2\]/<\/h2>/g' $FILE
sed -i 's/\[h3]/<h3>/g' $FILE
sed -i 's/\[\/h3\]/<\/h3>/g' $FILE
# convert bold
sed -i 's/\[b]/<b>/g' $FILE
sed -i 's/\[\/b\]/<\/b>/g' $FILE
# convert cursive
sed -i 's/\[i]/<i>/g' $FILE
sed -i 's/\[\/i\]/<\/i>/g' $FILE
# convert underline
sed -i 's/\[u]/<u>/g' $FILE
sed -i 's/\[\/u\]/<\/u>/g' $FILE
# remove quotes
sed -i 's/\[quote\]/"/g' $FILE
sed -i 's/\[\/quote\]/"/g' $FILE
sed -i 's/\"]/">/g' $FILE
sed -i 's/\]/">/g' $FILE