Result is malformed and not what was expected
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
Start with the README examples and the signature and behavior of the m function, then reproduce the pretty_stitches call alongside the standalone svg_stitch(5, 10, 1, '/') result. Trace how nested arguments and the uses... splat are serialized; done means the generated SVG contains both symbols, all 2176 use elements in the intended location, balanced tags, and correct attribute values.
Written by the indexing model from the issue text.
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:
<svg viewBox="0 0 80 1360">
<g>
<symbol refX="0" viewBox="0 0 5 10" refY="0" id="stitch1" preserveAspectRatio="xMinYMin">
<g>
<path style="stroke-width: 1px; vector-effect: non-scaling-stroke" d="M 0.9569057743101286 9.703069233026724 L 4.956905774310129 0.7030692330267239 A 0.5 0.5 0 0 0 4.043094225" ⋯ 259507 bytes ⋯ "B{N0f8}(1.0,0.0,0.0)" width="5mm" y="1360mm" />
<use height="10mm" href="#stitch1" x="75mm" style="stroke: none; fill: RGB{N0f8}(1.0,0.0,0.0)" width="5mm" y="1360mm" />
<use height="10mm" href="#stitch1" x="80mm" style="stroke: none; fill: RGB{N0f8}(1.0,0.0,0.0)" width="5mm" y="1360mm" />
</g>
</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
"<path style="stroke-width: 1px; vector-effect: non-scaling-stroke" d="M 0.9569057743101286 9.703069233026724 L 4.956905774310129 0.7030692330267239 A 0.5 0.5 0 0 0 4.043094225689871 0.29693076697327614 L 0.04309422568987137 9.296930766973276 A 0.5 0.5 0 0 0 0.9569057743101286 9.703069233026724" />"
or more readably
<g>
<path style="stroke-width: 1px; vector-effect: non-scaling-stroke"
d="M 0.9569057743101286 9.703069233026724 L 4.956905774310129 0.7030692330267239 A 0.5 0.5 0 0 0 4.043094225689871 0.29693076697327614 L 0.04309422568987137 9.296930766973276 A 0.5 0.5 0 0 0 0.9569057743101286 9.703069233026724" />
</g>
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.
- Dominant language
- Julia
- Stars
- 105
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaWeb/Hyperscript.jl
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
JuliaWeb/Hyperscript.jl#46 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
JuliaWeb/Hyperscript.jl#44 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
JuliaWeb/Hyperscript.jl#40 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
JuliaWeb/Hyperscript.jl#37 ·
-
Feature request: do-block syntaxPossibly taken @schneiderfelipe claimed this 2000 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
JuliaWeb/Hyperscript.jl#32 ·
All issues in JuliaWeb/Hyperscript.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaDiff/ChainRules.jl#871 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
JuliaStats/LogExpFunctions.jl#134 · 2 comments ·