Ejemplo n.º 1
0
        /// <summary>
        ///     Fixes the provided string
        /// </summary>
        /// <param name="input">Text to fix</param>
        /// <param name="output">Fixed text</param>
        /// <param name="fixTextTags"></param>
        /// <param name="preserveNumbers"></param>
        /// <param name="farsi"></param>
        /// <returns>Fixed text</returns>
        public static void FixRTL(
            string input,
            FastStringBuilder output,
            bool farsi           = true,
            bool fixTextTags     = true,
            bool preserveNumbers = false)
        {
            inputBuilder.SetValue(input);

            TashkeelFixer.RemoveTashkeel(inputBuilder);

            // The shape of the letters in shapeFixedLetters is fixed according to their position in word. But the flow of the text is not fixed.
            GlyphFixer.Fix(inputBuilder, glyphFixerOutput, preserveNumbers, farsi, fixTextTags);

            //Restore tashkeel to their places.
            TashkeelFixer.RestoreTashkeel(glyphFixerOutput);

            // Fix flow of the text and put the result in FinalLetters field
            LigatureFixer.Fix(glyphFixerOutput, output, farsi, fixTextTags, preserveNumbers);
            if (fixTextTags)
            {
                RichTextFixer.Fix(output);
            }
            inputBuilder.Clear();
        }
Ejemplo n.º 2
0
        public void Fix_Reverses_SimpleOpenAndClosingTagWithValue()
        {
            // Arrange
            var text = new FastStringBuilder("text </open> text <open=134>");

            // Act
            RichTextFixer.Fix(text);

            // Assert
            Assert.AreEqual("text >nepo/< text >431=nepo<", text.ToString());
        }
Ejemplo n.º 3
0
        public void Fix_Reverses_OpenTag_ThatDoesntHaveClosingTag()
        {
            // Arrange
            var text = new FastStringBuilder("text <open> text");

            // Act
            RichTextFixer.Fix(text);

            // Assert
            Assert.AreEqual("text >nepo< text", text.ToString());
        }
Ejemplo n.º 4
0
        public void Fix_Reverses_SelfContainedTags()
        {
            // Arrange
            var text = new FastStringBuilder("text <self-contained/> text");

            // Act
            RichTextFixer.Fix(text);

            // Assert
            Assert.AreEqual("text >/deniatnoc-fles< text", text.ToString());
        }