Commit Graph

17 Commits

Author SHA1 Message Date
Emi Tatsuo 3dadcc05ba
Merge remote-tracking branch 'upstream/main' into alt-text
continuous-integration/drone/pr Build is passing Details
2020-12-10 11:04:22 -05:00
Emi Tatsuo e44decab07
Merge remote-tracking branch 'upstream/main' into blank-line-doctest
continuous-integration/drone/pr Build is passing Details
2020-12-07 18:27:26 -05:00
Cadey Ratio cf73a3bb1e Merge pull request 'Add a `blank_line()` method to `Builder`' (#13) from alch_emii/maj-prs:blank-line into main
continuous-integration/drone/push Build is failing Details
Reviewed-on: #13
2020-12-06 01:14:19 +00:00
Emii Tatsuo 9bc2ea1159
Fix bug with type inferring for the `preformatted()` method
continuous-integration/drone/pr Build encountered an error Details
2020-11-30 14:17:13 -05:00
Emii Tatsuo 4c86fbba1e
Add support for alt-text in preformatted blocks ⚠️
continuous-integration/drone/pr Build is failing Details
⚠️  Breaking Change ⚠️

This adds support for parsing and rendering alt-text in preformatted blocks.  This changes the public API both around the `Node` enum and the `preformatted()` method of the builder.  I cannot think of a way to avoid this that is not needlessly overcomplicated, except maybe merging the preformatted & body into a single newline delimited string but that's hella gross and i don't think anyone wants that.  Lemme know if you can think of a better way of doing this

Preformatted blocks without alt text can still be created by passing in an empty string.  Because alt text isn't separated by a space, this does not add any unnecessary padding.  I chose not to accept Option<String> here because an empty string serves the same function but encourages users to use alt-text in their documents, which is very important for increasing accessibility.
2020-11-30 14:05:12 -05:00
Emii Tatsuo a7fabdc909
Allow Builder as Into<Vec<Node>>
continuous-integration/drone/pr Build encountered an error Details
2020-11-30 01:40:23 -05:00
Emii Tatsuo adf82e9d9b
Add a doctest for the `blank_line()` method
continuous-integration/drone/pr Build is passing Details
This adds a simple doctest for `blank_line()` but will not be included in the original PR because it is contingent on the merge of a pending PR for adding the `to_string()` method.
2020-11-30 01:17:41 -05:00
Emii Tatsuo c69ec3b7df
Merge branch 'to-string' into blank-line 2020-11-30 01:16:37 -05:00
Emii Tatsuo ac88fb60ee
Add a `blank_line()` method to `Builder`
continuous-integration/drone/pr Build is failing Details
Many times users may want to seperate lines of text using a blank line.  Currently, this can be accomplished by either adding '\n' to the previous `text()` call, which requires that the user has the ability to access this, and can also look a little messy, or by calling `text()` with an empty string, which definately works, but having an explicit method might be a nice sugar for a lot of users, and barely adds any weight to the codebase.

This is definately a small thing, and almost closer to a personal preferance than anything, but I definately think it would make the library a tiny bit nicer to use, and there's barely any tradeoff.  It's still up to you though if you'd rather keep your codebase small.
2020-11-30 01:11:12 -05:00
Emii Tatsuo 2f3dd72d90
Add AsRef and AsMut<[Node]> to builder
continuous-integration/drone/pr Build encountered an error Details
2020-11-30 00:52:08 -05:00
Emii Tatsuo 34dca8d92d
Impl ToString for Builder, accept AsRef<[Node]> in `render()`
continuous-integration/drone/pr Build is failing Details
This adds a to_string method to the `Builder` allowing for the easy conversion of a Vec<Node> into a String, for any usecases where a library might not be directly writing to an io::Write, or may want to do String-y things with your document first.  Without this, users would have to write to a Vec<u8> and convert to a String, which is kinda unintuitive, takes a lot of steps, and doesn't produce very readable code.  This simplifies it to one method call.

* Implementation of the std::str::ToString method for Builder
* Accepting any AsRef<[Node]> in render (including accepting the old Vec<Node>, so not breaking)
* Addition of estimate_len() to Node, used to pre-allocate the correct size of the String buffer

* `estimate_len` has some quick doctests and examples.  I know most of the rest of the project uses test methods, but I hope this is alright given that the tests may add some more clarity to the purpose and function of the method.
* `to_string` has a single line of unsafe code.  As the associated comment explains, this is provably safe, and exists just to avoid having to choose between having a bunch of duplicate code or inefficiently performing a UTF-8 check on a whole bunch bytes that we already know are safe.  That said, I totally get it if you're just generally against unsafe code and will change it to be an alternative if you so wish
* ToString is implemented instead of Display.  This is to discourage users from directly using this in a println!() or write!() macro, which would not be a thing you would normally expect to do with this.  It also gives us the advantage of being able to pre-allocate a buffer size, meaning less expensive String resizing.
* I couldn't think of a clever way to get `render()` to work with both `io::Write`s or `fmt::Write`s without duplicating the code, but I'm dumb and might be missing something, so if there's a way to do that instead of doing my funky unsafe hack that's cool and I can do that instead.
2020-11-29 23:17:15 -05:00
Cadey Ratio bebfa4d7b1 release gemtext 0.2.1 with clone fix from @boringcactus
continuous-integration/drone/push Build is passing Details
2020-10-06 17:43:42 -04:00
Melody Horn c07d81077a make gemtext::Node `Clone`
continuous-integration/drone/pr Build is passing Details
2020-10-05 04:38:19 -06:00
Cadey Ratio d437ac6e8f version bump for gemtext
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-09-26 19:21:03 -04:00
Melody Horn 3cd71ce302 escape special prefixes in plaintext nodes
continuous-integration/drone/pr Build is passing Details
2020-09-26 15:22:39 -06:00
Cadey Ratio 6058af8b44 update gemtext metadata for publication
continuous-integration/drone/push Build is failing Details
2020-08-08 16:11:02 -04:00
Cadey Ratio bae0ccb136 refactor gemtext tools into its own crate
continuous-integration/drone/push Build is failing Details
2020-08-08 16:10:20 -04:00