How to store text and formatting separately? - api

Let's say we have online text editor like google docs. There is a page with a formatted text there. Is it possible for backend to store the formatting and the text separately, without using markdown or html?
For example, the text is:
"Max brushes his teeth twice a day:
In the morning
In the evening"
Backend message would be like:
Text: "Max brushes his teeth twice a day:In the morningIn the evening"
Formatting:
4-11-bold
34-enter
34-48-numberedList
48-enter
48-62-numberedList
Where numbers is number of symbols to pass to apply formatting. Frontend will be parsing it to display for a reader.
What would be the limitations for such approach, except for obvious necessity to recalculate values for every text insert/delete?

Related

tcolorbox in RMarkdown with shortcuts

I'm using the LaTex library tcolorbox in a RMarkdown document to list R code with tbclisting{...}. It works fine when I use the full command is used in the document
\begin{tcblisting}{colback=red!5!white, colframe=red!50!black,listing only,before skip=5 cm,
title=R code for finding and plotting frequencies from sorted data - Figure 3.5,hbox, enhanced, drop fuzzy shadow, listing options={language=R,keywordstyle=\color{blue}},before=\begin{center}, after=\end{center}}
some text
\end{tcblisting}
Due to the length of the command and the multiple use of similar boxes, changing each box to reflect, say, a new color, is tedious and error prone. I'd like to create a short cut using
\newtcblisting{mybox}[1]{%colback=red!5!white, colframe=red!50!black,listing only,before skip=5 cm,title={#1},hbox, enhanced, drop fuzzy shadow, listing options={language=R,keywordstyle=\color{blue}}, before=\begin{center}, after=\end{center}}
in the preamble as in the LaTex documentation, then implemented using
when I refer to the predefined box using
\begin{mybox}{my box title}
some text
\end{mybox}
but the compiler-to-pdf gives me an error message
**!Package pgfkeys Error: I do not know the key '/tcb/[' and I am going to ignore it. Perhaps you misspelled it.**
I'm thinking that 1) RMarkdown/tcolorbox doesn't support this or 2) something is wrong with my syntax. For 2) I've tried putting the newtcblisting definition in the preamble header-includes: section with the "-" preceding it (no good) and in the main body of the document w/o the "-". Also no good.
Can anyone help with this?

Problem with line breaks in PDF document generated by BIRT

I have some cell texts in a BIRT report which do not flow as nicely as I hoped.
For example,
The text is Long value resultwithaverylongname whichcannotbreak and I had hoped that it would be displayed like this:
Long value
resultwithaverylongname
whichcannotbreak
The render options are as follows:
renderOptions.setOutputFormat(IPDFRenderOption.OUTPUT_FORMAT_PDF);
renderOptions.setOption(IPDFRenderOption.PAGE_OVERFLOW, IPDFRenderOption.OUTPUT_TO_MULTIPLE_PAGES);
renderOptions.setOption(IPDFRenderOption.PDF_TEXT_WRAPPING, true);
renderOptions.setOption(IPDFRenderOption.PDF_WORDBREAK, true);
It seems to me that my desired output is physically possible but I don't know why BIRT does not break on a whitespace and breaks in the middle of the word.
I am using BIRT 4.16 (from Sourceforge). The texts contain normal whitespace (no non-breakable spaces) and are displayed via a data object.
3.Sep.21
I now have an example project which I am trying to commit to Github. In the meantime here is a screenshot showing breaks which look good and others which are not...
The git repo is here: https://github.com/pramsden/test.wordbreak
If the text "resultwithaverylongname" physically fits, then you are right:
BIRT should not break it in the middle of the word.
Your renderOptions seem right (depending of what BIRT version you are using).
At first glance this looks like a bug.
But: In German language, we often have quite long words, and I've created a lot of (complex) PDF reports with BIRT, but I never saw this issue.
So I guess it is a tiny silly detail which causes this.
Just to double-check:
Are the spaces between "Long", "value", "result..." normal spaces (0x20)? or non-breaking spaces?
Which BIRT release are you using?
Are you using a data item or a dynamic text item and if so, is it HTML or plain text?
Can you create a reproducible simple test case and post the rptdesign file somewhere?
well i don use BIRT , but try to use (\n),
in my case I use PDFFlow library to generate pdf docs, and to make a line-break i just use \n
this is a simple example code to create a pdf file and use line break
var DocumentBuilder.New()
.AddSection()
.AddParagraphToSection("Hello world! \n go to the next line")
.ToDocument()
.Build("Result.PDF");
try it and tell me if it works

How to extract specific lines from a text document?

I am no expert in coding or anything but I figured it out this website would be the best to achieve what I want. So, I got my personal data from Spotify, and they give you how much you played a song and all of the play history and I want to calculate how much I listened in total, the problem is I don't know how can I extract the specific lines from the text document with only the time and then calculate it.
The text is something like this:
{
"endTime" : "2020-11-21 22:23",
"artistName" : "Kanye West",
"trackName" : "Devil In A New Dress",
"msPlayed" : 351946
},
and there are a lot of songs, I just want to extract the "msPlayed" thing so I can calculate it, any help?
Go here: https://regex101.com/r/RLDYUj/1
Put your text into the "Test String" part
Copy in your clipboard the numbers list in the "Substitution" part
Go here: https://miniwebtool.com/sum-calculator/
Paste the numbers list and compute the sum

In Jira Wiki format only part of word

When i write in Jira wiki page:
player*Id*
I want only part of word to be formatted (bold): "Id". But jira writes it literaly:
player*Id*
I want it to write:
playerId
If i make whole playerId bold, it works though. How to make only part of word bold in jira wiki?
I think it's not possible, as parser requires spaces next to asterisks to display it correctly.
What you can do is to use color instead:
Player{color:red}Id{color}
Which would be displayed like this:

how can i export DataGridView with ARABIC data from Visual Basic to PDF by using iTextSharp [duplicate]

I have a problem with inserting UNICODE characters in a PDF file in eclipse.
There is some solution for this that it is not very efficient for me.
The solution is like this.
document.add(new Paragraph("Unicode: \u0418", new Font(bfComic, 12)));
I want to retrieve data from a database and show them to the user and my characters are in Arabic script and sometimes in Farsi script.
What solution do you suggest?
thanks
You are experiencing different problems:
Encoding of the data:
Please download chapter 2 of my book and go to section 2.2.2 entitled "The Phrase object: a List of Chunks with leading". In this section, look for the title "Database encoding versus the default CharSet used by the JVM".
You will see that database values are retrieved like this:
String name1 = new String(rs.getBytes("given_name"), "UTF-8");
That’s because the database contains different names with special characters. You risk that these special characters are displayed as gibberish if you would retrieve the field like this:
String name2 = rs.getString("given_name")
Encoding of the font:
You create your font like this:
Font font = new Font(bfComic, 12);
You don't show how you create bfComic, but I assume that this object is a BaseFont object using IDENTITY_H as encoding.
Writing from right to left / making ligatures
Although your code will work to show a single character, it won't work to show a sentence correctly.
Suppose that name1 is the Arabic version of the name "Lawrence of Arabia" and that we want to write this name to a PDF. This is done three times in the following screen shot:
The first line is wrong, because the characters are in the wrong order. They are written from left to right whereas they should be written from right to left. This is what will happen when you do:
document.add(name1);
Even if the encoding is correct, you're rendering the text incorrectly.
The second line is also wrong. The characters are now in the correct order, but no ligatures are made: ل followed by و should be combined into a single glyph: لو
You can only achieve this by adding the content to a ColumnText or PdfPCell object, and by setting the run direction to PdfWriter.RUN_DIRECTION_RTL. For instance:
pdfCell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
Now the text will be rendered correctly.
This is explained in chapter 11 of my book. You can find a full example here: Ligatures2