Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
aklt committed May 10, 2024
1 parent 0dccdb3 commit a368ff3
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 64 deletions.
92 changes: 73 additions & 19 deletions index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,71 @@ cat << EOHEADER
<link rel="stylesheet" href="style.css" type="text/css" />
<style>
body {
background-color: #444;
background-color: #CCC;
font-size: 14pt;
font-family: arial, sans-serif;
}
img {
margin-left: 2em;
figure {
margin-left: 1em;
flex: 1 0 0;
overflow: auto;
}
h1, h2 {
color: #AAA;
text-align: center;
}
h2 {
font-size: 120%;
margin: 1em 0 0 0;
font-size: 140%;
margin: 1em 2em;
}
a {
text-decoration: none;
color: #7AF;
color: #58C;
}
li {
list-style-type: none;
}
.wrap {
display: flex;
min-height: 100dvh;
margin: 0 auto;
}
.two {
display: flex;
gap: 1em;
overflow: auto;
}
svg {
width: 240%;
height: 240%;
}
section {
margin: 1em;
padding: 1em;
flex: 1 0 0;
width: fit-content;
}
nav {
position: sticky;
top: 0;
height: 100dvh;
overflow-y: auto;
background-color: #CCC;
padding: 1em;
min-width: 30%;
max-width: 300px;
font-size: 16pt;
}
nav > ul {
position: relative;
top: 0;
}
EOHEADER

echo "/* Styles from vim */"
cat uml/*.css | sort -u

cat << "EOREST";
</style>
</head>
<body>
Expand All @@ -36,25 +82,33 @@ cat << EOHEADER
Generated by <a href="https://github.com/aklt/plantuml-syntax-test">Plantuml syntax Test</a>.
</p>
EOHEADER
EOREST

echo "<ul>"
echo '<div class="wrap">'
echo "<nav><ul>"
for i in $(echo "$@" | tr ' ' '\n' | sort); do
baseName=$(echo "$i" | sed -e 's/^\([^.]\+\).*$/\1/')
echo "<li><a href=\"#$baseName\">$baseName</a></li>"
baseName=$(echo "$i" | sed -e 's/^uml\///' -e 's/\.pre\.html$//')
titleName=$(echo "$baseName" | sed -e 's/^uml\///' -e 's/^reference_//' -e 's/_/ /g')
echo "<li><a href=\"#$baseName\">$titleName</a></li>"
done
echo "</ul><hr />"
echo "</ul></nav>"

echo "<main>"
for i in $(echo "$@" | tr ' ' '\n' | sort); do
baseName=$(echo "$i" | sed -e 's/^\([^.]\+\).*$/\1/')
echo "<a name=\"$baseName\"></a><table><tr><td>"
echo "<h2>$baseName</h2>"
cat "$i"
echo "</td><td>"
echo "<img src=\"${baseName}.png\" />"
echo "</td></tr></table>"
echo "<hr />"
baseName=$(echo "$i" | sed -e 's/\.pre\.html$//')
anchorName=$(echo "$baseName" | sed -e 's/^uml\///')
titleName=$(echo "$baseName" | sed -e 's/^uml\///' -e 's/^reference_//' -e 's/_/ /g')
echo "<a name=\"$anchorName\"></a><section>"
echo "<h2>$titleName</h2>"
echo '<div class="two">'
cat "$i" | sed -e "s/ id='vimCodeElement'//"
echo "<figure>"
cat "${baseName}.svg" | sed -e 's/^<?xml version="1.0" encoding="us-ascii" standalone="no"?>//'
echo "</figure>"
echo "</div></section>"
done
echo "</main>"
echo "</div>"

cat << EOFOOTER
</body>
Expand Down
12 changes: 8 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ info:
all: build

par-png: $(UML)
$(MAKE) -j $(nproc) $(PNG)
$(MAKE) $(PNG)

par-svg: $(UML)
$(MAKE) -j $(nproc) $(SVG)
$(MAKE) $(SVG)

build: style.css index.html par-png
build: style.css index.html par-svg

style.css: $(CSS) $(UML)
cat $(CSS) | sort | uniq > $@

index.html: index.sh $(PRE) $(UML)
index.orig.html: index.sh $(PRE) $(UML)
bash ./index.sh $(PRE) > $@

index.html: index.orig.html
npx html-minifier-terser --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype \
--minify-urls --minify-js true --minify-css true $< > $@

%.pre.html %.syntax.css: %.uml
bash ./tohtml.sh $< uml/$$(basename $< .uml)

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
},
"homepage": "https://github.com/aklt/plantuml-syntax-test#readme",
"dependencies": {
"freshen": "^0.6.0"
"freshen": "^0.6.0",
"html-minifier-terser": "^7.2.0",
"htmlmin": "^0.0.7"
}
}
32 changes: 10 additions & 22 deletions tohtml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# Configure colorscheme and where to source plantuml-syntax/syntax/plantuml.vim
# from
#
colors="\$VIMRUNTIME/colors/default.vim"
# colors="\$VIMRUNTIME/colors/default.vim"
# colors="${HOME}/.vim/bundle/gruvbox/colors/gruvbox.vim"
# colors="${HOME}/.vim/bundle/papercolor-theme/colors/PaperColor.vim"
tools="tohtml.vim"

if [ -z "$1" ] || [ -z "$2" ]; then
Expand All @@ -15,28 +15,12 @@ if [ -z "$1" ] || [ -z "$2" ]; then
exit 1
fi

ft=$(echo "$1" | sed -e 's/^.\+\.\(\w\+\)$/\1/')

case "${ft}" in
uml)
ft='plantuml'
;;
esac

echo "ft ${ft}"

toHtml="$VIM_TO_HTML"
if ! [ -e "$toHtml" ]; then
toHtml="$HOME/install/share/vim/vim82/syntax/2html.vim"
fi
if ! [ -e "$toHtml" ]; then
toHtml="/usr/share/vim/vim82/syntax/2html.vim"
fi
if ! [ -e "$toHtml" ]; then
toHtml="$HOME/install/share/vim/vim81/syntax/2html.vim"
toHtml="$HOME/install/share/vim/vim90/syntax/2html.vim"
fi
if ! [ -e "$toHtml" ]; then
toHtml="/usr/share/vim/vim81/syntax/2html.vim"
toHtml="/usr/share/vim/vim90/syntax/2html.vim"
fi
if ! [ -e "$toHtml" ]; then
echo "Cannot find 2html.vim script, set VIM_TO_HTML variable"
Expand All @@ -48,8 +32,12 @@ tmpFile=$(mktemp /tmp/tohtml-sh.XXXX)
PACKPATH="`pwd`/vim"

vim --noplugin -u NONE \
-c ":source ${tools} | :source ${colors}" \
-c ":call IndentPlantUML('$1', '${ft}')" \
-c ":syntax on" \
-c ":set nocp" \
-c ":source ${tools}" \
-c ":set bg=light" \
-c ":colorscheme wildcharm" \
-c ":call IndentPlantUML('$1')" \
-c ":let g:loaded_2html_plugin = 0" \
-c ":source $toHtml" \
-c ":w! ${tmpFile}" \
Expand Down
4 changes: 2 additions & 2 deletions tohtml.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function! IndentPlantUML(filePath, fileType)
function! IndentPlantUML(filePath)
set nocp
syntax on
filetype plugin indent on
Expand All @@ -8,7 +8,7 @@ function! IndentPlantUML(filePath, fileType)
set shiftwidth=2
set tabstop=2
execute ":edit " . a:filePath
execute ":set ft=" . a:fileType
execute ":set ft=plantuml"
normal gg=G
write!
endfun
4 changes: 2 additions & 2 deletions uml/reference_16-01-02-1_Declaring-tasks-Start.uml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@startuml
@startgantt
[Prototype design] lasts 15 days
[Test prototype] lasts 10 days
Project starts 2020-07-01
[Prototype design] starts 2020-07-01
[Test prototype] starts 2020-07-16
@enduml
@endgantt
4 changes: 2 additions & 2 deletions uml/reference_16-01-03-1_Declaring-tasks-End.uml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@startuml
@startgantt
[Prototype design] lasts 15 days
[Test prototype] lasts 10 days
Project starts 2020-07-01
[Prototype design] ends 2020-07-15
[Test prototype] ends 2020-07-25
@enduml
@endgantt
4 changes: 2 additions & 2 deletions uml/reference_16-01-04-1_StartEnd.uml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@startuml
@startgantt
Project starts 2020-07-01
[Prototype design] starts 2020-07-01
[Test prototype] starts 2020-07-16
[Prototype design] ends 2020-07-15
[Test prototype] ends 2020-07-25
@enduml
@endgantt
2 changes: 1 addition & 1 deletion uml/reference_16-02-1_One-line-declaration.uml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startgantt
Project starts 2020-07-01
[Prototype design] starts 2020-07-01 and ends 2020-07-15
[Test prototype] starts 2020-07-16 and lasts 10 days
Expand Down
4 changes: 2 additions & 2 deletions uml/reference_16-11-01-1_Changing-scale-Daily.uml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startgantt
saturday are closed
sunday are closed
Project starts the 1st of january 2021
Expand All @@ -8,4 +8,4 @@ Project starts the 1st of january 2021
[TASK1]->[Testing]
2021-01-18 to 2021-01-22 are named [End's committee]
2021-01-18 to 2021-01-22 are colored in salmon
@enduml
@endgantt
4 changes: 2 additions & 2 deletions uml/reference_16-11-02-1_Changing-scale-Weekly.uml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startgantt
printscale weekly
saturday are closed
sunday are closed
Expand All @@ -9,4 +9,4 @@ Project starts the 1st of january 2021
[TASK1]->[Testing]
2021-01-18 to 2021-01-22 are named [End's committee]
2021-01-18 to 2021-01-22 are colored in salmon
@enduml
@endgantt
4 changes: 2 additions & 2 deletions uml/reference_16-21-2_Change-link-colors.uml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startgantt
<style>
ganttDiagram {
arrow {
Expand All @@ -12,4 +12,4 @@ LineColor blue
[Prototype design] -[#FF00FF]-> [Build prototype]
[Prototype design] -[dotted]-> [Prepare test]
Then [Run test] lasts 4 days
@enduml
@endgantt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startgantt
header some header
footer some footer
title My title
Expand All @@ -7,4 +7,4 @@ legend
The legend
end legend
caption This is caption
@enduml
@endgantt
2 changes: 1 addition & 1 deletion vim/pack/test/opt/plantuml-syntax

0 comments on commit a368ff3

Please sign in to comment.