Skip to content

Commit

Permalink
Create generic ftl serializer (#241)
Browse files Browse the repository at this point in the history
* Start writing up the serializer

* Made sure indentation is handled properly

* Started handling select expressions

* Switched "    " to "\t" to make recognising indents easier

* Everything from TypeScript's "Serialize resource" test suite passes

* Added the rest of the tests

* Added a test to make sure subsequent entries with a comment aren't separated by newlines

* Fix serializer for fluent-syntax 0.11.0

Botch with only `&str` supported.

* Fix empty lines in messages being swallowed

* Fix indentation of default asterisk

It seems like `*` is supposed to go _inside_ the indent now.

* Fix lints

* Make `serialize()` generic over `Slice`

* Handle rare edge case of line terminating `\r`

* Fix redundant line break after after junk

* Align parsing of CRLF-terminated patterns

`\r\n` was parsed as a separate TextElement of `\n`, whereas `\n` is
parsed as part of the antecedent TextElement.

* Don't break line before leading dot pattern

* Don't implicitly trim when writing literals

* Replace roundtrip tests with manipulation tests

* Reintroduce roundtrip tests

* Move old fixtures into resource files.
* Test on unnormalized fixtures as well.

* Fix clippy lints

* Document serializer mod and pub functions

Also make Serializer private.

* Replace unwrap with expect

* Remove redundant error propogation

* BLACKLIST -> IGNORE_LIST

* Fix typo

* Mention serializer on changelog

* Revert c009674 and add crlf.ftl to ignore list

Co-authored-by: Michael Bryan <mbryan@autronics.com.au>
  • Loading branch information
RumovZ and Michael Bryan committed Nov 10, 2022
1 parent d53526f commit 00f1499
Show file tree
Hide file tree
Showing 11 changed files with 832 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fluent-syntax/CHANGELOG.md
@@ -1,7 +1,7 @@
# Changelog

## Unreleased

- Add module `serializer`.
-

## fluent-syntax 0.11.0 (February 9, 2021)
Expand Down
1 change: 1 addition & 0 deletions fluent-syntax/src/lib.rs
Expand Up @@ -48,4 +48,5 @@
//! ```
pub mod ast;
pub mod parser;
pub mod serializer;
pub mod unicode;

0 comments on commit 00f1499

Please sign in to comment.