Open rochecompaan opened 4 years ago
I'd like to second this. I tried with the demo text for my part.
@rochecompaan @Melandel thanks, for reporting this issue. I'll take a look into this.
Unfortunately, I wasn't able to replicate this. I used the same test .bob
, but it had styles on it.
Can you post the used cli commands and the generated svg image?
@rochecompaan @Melandel I've pushed in a new commit setting the exact version of svgbob from the cli. Perhaps it would solve the issue.
:(
Still don't have styles.
Maybe I'm doing things wrong?
Here's what I did:
Edit: I'm on Windows 10. Does that change anything?
Maybe the photo-viewer you are showing might now be rendering the svg correctly. Try opening the svg image using firefox or chrome.
It would help if you could post your .bob
input and a screenshot, or the generated svg text.
Here is what I've generated based the the input above.
https://imgur.com/a/aUoYhbw
I first tried on Debian installed in WSL2 and got the following SVG output for the input text I posted originally:
I tried on Windows 10 as well and got the following output:
No styling appears in Edge, Firefox or Chrome for any of the platforms.
I tried the input above and got this in firefox on Windows 10:
@Melandel , try doing a cargo update
on svgbob and in svgbob_cli
. It looks like Cargo.lock
is included in the repo. I'm going to delete Cargo.lock
in the next commits.
I tried a cargo update
on the three folders (svgbob
, svgbob/svgbob
and svgbob/svgbob_cli
) on a fresh clone of the repo.
The issue persists :(
My knowledge of Rust is absolutely inexistant, but I managed to find out that the css parsing fails on my machine maybe because windows newline characters cause some trouble.
Substituting
pub fn new_line<'a>() -> Parser<'a, char, ()> {
one_of("\n").discard()
}
with
pub fn new_line<'a>() -> Parser<'a, char, ()> {
one_of("\r\n").discard()
}
allows
impl From<&str> for CellBuffer {
fn from(input: &str) -> Self {
let css_styles = if let Some(loc) = input.find("# Legend:") {
if let Ok(css_styles) = parser::parse_css_legend(&input[loc..]) {
Some((loc, css_styles))
} else {
None
}
} else {
None
};
/// [...]
}
}
to validate parser::parse_css_legend(&input[loc..])
, whereas with no substitution the code goes directly into the None
branch.
However, unless my println
technique is flawed (because I don't really understand anything about the syntax I'm using for the moment haha), even after substitution the variable css_styles
seems to be an empty array.
I can confirm it's an issue linked to the end-of-line characters.
I got the colors (I got the colors !! 😹) when I switch the fileformat from dos
to unix
.
This is a nice workaround, but I still think it would be interesting to handle dos end of line characters.
What do you think?
It's working for me once I switch to Unix line endings. +1 for adding support for CRLF as well.
Thank you all for filing the issue and finding the root cause.
I just published a new version of with support of carriage return \r
. Please help me test it out.
@ivanceras it's not working on the latest master.
First, thank you for an awesome package!
I installed a nightly build of rust and ran
cargo build
on a clone ofmaster
and I also tried therewrite3-vectorize
branch.If I generate the diagram with the CLI version eg
svgbob page.txt -o page.svg
, none of the styles are applied. If I use the online editor at https://ivanceras.github.io/svgbob-editor/, it works fine. What could be wrong?I use the following input: