JuliaWeb / JuliaWeb/Hyperscript.jl
Result is malformed and not what was expected
- Dominant language
- Julia
- Stars
- 105
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
I'm having a problem with HyperScript.jl.
This function
```
function pretty_stitches(image_stitches, flip_right_to_left::Bool)
# image_stitches should be the top_image_stitches or bottom_image_stitches
# of a TabletWeavingPattern.
stitch_width = 5
stitch_length = 10
stitch_diameter = 1
uses = []
function use(row, col, color, slant)
push!(uses,
m("use",
href = slant == '/' ? "#stitch1" : "#stitch2",
x="$(col * stitch_width)mm",
y="$(row * stitch_length)mm",
width="$(stitch_width)mm",
height="$(stitch_length)mm",
style="stroke: none; fill: $(color)"))
end
for (rownum, row) in enumerate(image_stitches)
for (colnum, stitch) in enumerate(row)
(color, slant) = stitch
use(rownum, colnum, color, slant)
end
end
println(length(uses))
m("svg",
viewBox="0 0 $(stitch_width * length(image_stitches[1])) $(stitch_length * length(image_stitches))",
m("g",
m("symbol", id="stitch1",
preserveAspectRatio="xMinYMin",
viewBox="0 0 $(stitch_width) $(stitch_length)",
refX="0", refY="0",
svg_stitch(stitch_width, stitch_length, stitch_diameter, '/';)),
m("symbol", id="stitch2",
preserveAspectRatio="xMinYMin",
viewBox="0 0 $(stitch_width) $(stitch_length)",
refX="0", refY="0",
svg_stitch(stitch_width, stitch_length, stitch_diameter, '\\';)),
uses...)
)
end
```
(you can focus on the Hyperscript calls to generate SVG at the end) produces this SVG:
```
```
(which has been stringified and reformatted for readability).
Note that it also genrates the printed output
```
`uses` has 2176 elements.
```
The call
```
string(svg_stitch(5, 10, 1, '/';))
```
returns
""
or more readably
```
```
That is what the content of each of the symbols should look like.
Why do the close tags in the output of `pretty_stitches` not balance?
Where is the second `symbol` element?
Why are the `use` elements nested within the symbol's group rather
than after the symbol?
Why are there only two `use` elements when there should be 2176?
Why do the attributes of an element appear in a different order in the SVG than in the source code? Maybe use OrderedDict?
Perhaps I'm misusing the `m` function? My use is consistent with the examplesin the README file, but not with its function signature.
I prefer the `do` syntax that the `NativeSVG` package allows for, but that package is apparently no longer maintained.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.