Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to avoid Paragraph around single element #59

Open
GoogleCodeExporter opened this issue Mar 14, 2016 · 0 comments
Open

Add option to avoid Paragraph around single element #59

GoogleCodeExporter opened this issue Mar 14, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. I need to have this block of text "test" to be translated into "test" and 
not in "<p>test</p>"

I've modified source code to obtain this, but i like to download this fix with 
your future fixes.

Also i will send you my fix so you can evaluate if this modification can be 
embedded in main project :-)


In few words: i have added WrapWithParagraph option and modified some code in 
FormParagraph method:
private string FormParagraphs(string text)
        {
            // split on two or more newlines
            string[] grafs = _newlinesMultiple.Split(_newlinesLeadingTrailing.Replace(text, ""));

            //20130426 - Michele Piccinini - if there is only one graf i don't wrap it with P tag
            if (!_WrapWithParagraph && grafs.Length == 1)
            {
                if (grafs[0].StartsWith("\x1A"))
                {
                    grafs[0] = _htmlBlocks[grafs[0]];
                }
            }
            else
            {
                for (int i = 0; i < grafs.Length; i++)
                {
                    if (grafs[i].StartsWith("\x1A"))
                    {
                        // unhashify HTML blocks
                        grafs[i] = _htmlBlocks[grafs[i]];
                    }
                    else
                    {
                        // do span level processing inside the block, then wrap result in <p> tags
                        grafs[i] = _leadingWhitespace.Replace(RunSpanGamut(grafs[i]), "<p>") + "</p>";
                    }
                }
            }
            return string.Join("\n\n", grafs);
        }

Original issue reported on code.google.com by mich...@jeminet.it on 26 Apr 2013 at 12:50

Attachments:

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

No branches or pull requests

1 participant