Skip to content

Creates script that formats apostrophes/quotes nicely if outside of c… - #380

Closed
lancelafontaine wants to merge 2 commits into
rust-lang:masterfrom
lancelafontaine:363-remove-curly
Closed

Creates script that formats apostrophes/quotes nicely if outside of c…#380
lancelafontaine wants to merge 2 commits into
rust-lang:masterfrom
lancelafontaine:363-remove-curly

Conversation

@lancelafontaine

Copy link
Copy Markdown
Contributor

…ode block, inline code or html tag; applies it to all markdown files in project.

This is my first Rust program ever, so hopefully it isn’t too much “spaghetti code”. If you can let me know how I can improve it, I will!

I applied it to all markdown files in the project with for f in ./**/*.md; do; cat "$f" | ./target/debug/quote2curly | tee "$f"; done;. I looked most of the output and it looks good to me.

This script considers that all " in html tags are within one line. The only outcome of this is that commented paragraphs also get parse and formatted.

…ode block, inline code or html tag; applies it to all markdown files in project.

@steveklabnik steveklabnik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one tiny thing 😄

Comment thread tools/src/bin/quote2curly.rs Outdated
}
else {
let mut modified_line = &mut String::new();
let mut previous_char = '⌨'; // default non-alphanumeric char

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I was looking for something along those lines and resulted to using an arbitrary character. Fixed in caf951f.

@carols10cents

Copy link
Copy Markdown
Member

Nice work, this is looking great and will be really useful!!! I'm sorry that I've taken so long to get back to you!

I found one edge case, on this line in the diff: https://github.com/rust-lang/book/pull/380/files#diff-3050b578efb0fc3da82cb00232968d03L223

I would have expected the quotes within the inline code to be unchanged, but they have been changed. The strange thing is if I put that line in its own file, it doesn't change the quotes, as I expect. So I'm not sure what it is, but something about the content before then in chapter 1 is confusing is_in_inline_code? Also just after that are some missed quotes, but by line 243 it's replacing things properly again...

Do you mind taking a look into what's going on?

Thanks!!! I'm honored we're your first Rust code!!! ❤️

@lancelafontaine

Copy link
Copy Markdown
Contributor Author

Hmm, that is strange. I'll have time in a couple days to investigate (and fix the merge conflict). I'll post back soon!

@steveklabnik

Copy link
Copy Markdown
Contributor

@lancelafontaine whew, a bunch of stuff has changed since January. Any interest in keeping this going?

@lancelafontaine

Copy link
Copy Markdown
Contributor Author

Hey @steveklabnik, sorry for dropping off the face of the earth. I've got a few other commitments I have to finish before getting back to this, but would likely be able to pick it back up in a few weeks. If anyone else is interested in looking into this before then that would be great! Otherwise I would be happy to pick it up again soon.

@steveklabnik

Copy link
Copy Markdown
Contributor

@lancelafontaine zero worries, I certainly know how that goes. 😄

@lancelafontaine

lancelafontaine commented Apr 25, 2017

Copy link
Copy Markdown
Contributor Author

I should have time to pick this back up over the next couple of days @steveklabnik @carols10cents. I'll submit a new PR after revisiting it :).

@lancelafontaine

Copy link
Copy Markdown
Contributor Author

I'll close this pull request and open another one up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants