Coder Social home page Coder Social logo

Command line stdin conversion about svgbob HOT 6 CLOSED

ivanceras avatar ivanceras commented on July 28, 2024
Command line stdin conversion

from svgbob.

Comments (6)

ivanceras avatar ivanceras commented on July 28, 2024

Make sure you installed svgbob_cli via cargo install -f svgbob_cli.
Invoke the command with svgbob
Trying out your example:

$> echo "+--+\n| |\n+--+" | svgbob
<svg class="bob" font-family="arial" font-size="14" height="16" width="120" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="triangle" markerHeight="10" markerUnits="strokeWidth" markerWidth="10" orient="auto" refX="15" refY="10" viewBox="0 0 50 20">
<path d="M 0 0 L 30 10 L 0 20 z"/>
</marker>
</defs>
<style>

    line, path {
      stroke: black;
      stroke-width: 2;
      stroke-opacity: 1;
      fill-opacity: 1;
      stroke-linecap: round;
      stroke-linejoin: miter;
    }
    circle {
      stroke: black;
      stroke-width: 2;
      stroke-opacity: 1;
      fill-opacity: 1;
      stroke-linecap: round;
      stroke-linejoin: miter;
    }
    circle.solid {
      fill:black;
    }
    circle.open {
      fill:transparent;
    }
    tspan.head{
        fill: none;
        stroke: none;
    }
    
</style>
<path d=" M 4 8 L 8 8 L 16 8 M 8 8 L 16 8 L 24 8 M 16 8 L 24 8 M 28 8 L 24 8 M 40 16 L 32 0 L 40 16 M 68 0 L 68 16 M 68 0 L 68 16 M 80 16 L 72 0 L 80 16 M 92 8 L 96 8 L 104 8 M 96 8 L 104 8 L 112 8 M 104 8 L 112 8 M 116 8 L 112 8" fill="none"/>
<path d="" fill="none" stroke-dasharray="3 3"/>
<text x="41" y="12">
n|
</text>
<text x="81" y="12">
n
</text>
</svg>

from svgbob.

yhql avatar yhql commented on July 28, 2024

Thanks for looking into that. I also get some result with the example you tested, but here is what the svg you posted looks like :

svg

(in the svg you can also see that the \n are actually written as <text>n</text>)
When using an external file (with actual newline characters) :

svg3

I get something slightly different with the same command line, so I will perform the installation like you said, but I think the newline character will still be handled the same way :

svg2

from svgbob.

ivanceras avatar ivanceras commented on July 28, 2024

Hi, it looks like a huge bug, probably with the added " as escaping character to be not interpreted as graphics. I've to look at this further.

from svgbob.

ivanceras avatar ivanceras commented on July 28, 2024

@yhql it looks like this is not an issue with svgbob at all, but echo is sending literal "\n". That needs to be an actual line. Try putting -e instead with echo -e "+--+\n| |\n+--+" | svgbob.
Alternatively you can also try printf "+--+\n| |\n+--+" | svgbob as stated here https://stackoverflow.com/questions/8467424/echo-newline-in-bash-prints-literal-n

from svgbob.

yhql avatar yhql commented on July 28, 2024

Thanks for the info. Sadly as I'm on windows the echo command does not have any special flags that would help.
I did try the following trick :
echo "+--+" & echo "| |" & echo "+--+" | svgbob
which almost does the job : the drawing is correct but there seems to be no way of getting rid of the " characters in the result.

from svgbob.

yhql avatar yhql commented on July 28, 2024

If you're ok with it I could try to make svgbob accept strings as first arguments so that it handles the \n and others by itself, rather than let the terminal deal with it (because I don't see any way around on Windows).

from svgbob.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.