I am trying to read two json files from my local php server using fetch
1.captions.json, which is an array
[]
2.presentation_text.json, which is an object
{
"5b4110b08dc92531df26a22dd23de13924e3c4c5-1665291983611": {
"slide-1": "A Simple PDF File\nThis is a small demonstration .pdf file -\njust for use in the Virtual Mechanics tutorials. More text. And more\ntext. And more text. And more text. And more text.\nAnd more text. And more text. And more text. And more text. And more\ntext. And more text. Boring, zzzzz. And more text. And more text. And\nmore text. And more text. And more text. And more text. And more text.\nAnd more text. And more text.\nAnd more text. And more text. And more text. And more text. And more\ntext. And more text. And more text. Even more. Continued on page 2 ...\n",
"slide-2": "Simple PDF File 2\n...continued from page 1. Yet more text. And more text. And more text.\nAnd more text. And more text. And more text. And more text. And more\ntext. Oh, how boring typing this stuff. But not as boring as watching\npaint dry. And more text. And more text. And more text. And more text.\nBoring. More, a little more text. The end, and just as well.\n"
}
}
When i try to make an ajax call I am getting 200 for both files.
For captions.json i can see the json data
https://imgur.com/a/RcwRuVG
But for presentation_text.json I cant see the data, but getting failed to load response
https://imgur.com/a/7IOCHec
So i tried to change it from object to array and i can see the output
https://imgur.com/a/gkR3Ouw
How can i read the object from presentation_text.json.
Related
I am trying to generate a report consisting of plots and some text using Bokeh 2.0.1, and I am trying to preserve the original line gaps in the text that I feed into bokeh.layouts.gridplot.
However, I see that all the line gaps get removed after the HTML file is generated, and essentially, all paragraphs get merged into one continuous sentence. I am not sure why that is happening. I didn't find much help in the Bokeh documentation regarding this issue.
Here's a minimal example of the section of the code I am trying to get to work.
from bokeh.layouts import gridplot
from bokeh.models import Paragraph
from bokeh.plotting import output_file, save
sampText = "PARAGRAPH 1: This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text.\n
PARAGRAPH 2: This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text. This is a minimal example of a text."
fig1 = ...
fig2 = ...
text = Paragraph(text = sampText, width = 1500, height_policy = "auto", style = {'fontsize': '10pt', 'color': 'black', 'font-family': 'arial'})
output_file(filename = "myMinimalExampleOutput" + ".html")
output = gridplot([fig1, fig2, text], ncols = 1, plot_width = 1500, sizing_mode = 'scale_width')
save(output)
Could someone please point out why this is happening?
This is how HTML works - it removes all "unnecessary" whitespace from the text.
For your two paragraphs to work, you have to wrap each of them in <p></p>. But since Paragraph generates the same tag, you can't use that class. Use the regular Div and set its text input parameter to the HTML that you want to be rendered.
Div(text='<p>paragraph 1</p><p>paragraph 2</p>')
I need to get the texts from HTML pages but some of them contain unnecessary texts which go after certain text in page ('---------').
E.g. example of HTML page 1:
...
<p> This is correct text. Everything after it is wrong</p>
<p>---------</p>
<p><strong>This is wrong text</strong></p>
<p> This is wrong another text</p>
...
Example of HTML page 2:
...
<p> This is correct text. Everything after it is wrong</p>
<p> This text is also valid </p>
<p> This is another correct text</p>
...
So if page contains '-----------------', I need to grab only texts before it otherways - I need to grab everything. As noted here (Get text followed by certain text) I can use:
//p[following-sibling::p[contains(.,'---------')]][1]/text()
For the 1st example. But is there a way to use one XPath for both cases?
//p[ not(contains(.,'---------'))
and not(preceding-sibling::p[contains(.,'---------')])]//text()
Will return
This is correct text. Everything after it is wrong
for your first case and
This is correct text. Everything after it is wrong
This text is also valid
This is another correct text
for your second case, as requested.
I am using Rockmongo as the UI, and I am trying to save something every similar to this.
text text's text. <p>text this is where the text goes</p><h1>haha</h1>
Now I am not sure if it is the .,' or even the ? <p> etc.
I was unable to reproduce this. Here is what I tried in the JavaScript shell:
> db.text.save({_id:1, text:"text text's text. <p>text this is where the text goes</p><h1>haha</h1>"})
> db.text.find()
{ "_id" : 1, "text" : "text text's text. <p>text this is where the text goes</p><h1>haha</h1>" }
The line was saved successfully. Are you surrounding the text string with double quotes " ? As bfavaretto mentioned, the issue could be from the single apostrophe in your string. The following will not work:
> db.text.drop()
true
> db.text.save({_id:1, text:'This is text with an extra ' apostrophe.'})
...
...
> db.text.find()
>
As you can see, the above document was not saved because the string was not properly formatted. In fact, the JS shell never even executed the command.
Mongo should be able to save a string containing all of these characters. If you are still having issues, perhaps this could be an issue with RockMongo? (Unfortunately, I am not familiar with this program.) A simple way to troubleshoot is to test saving each unique character one at a time, and see which character causes the issue. Hope this helps!
I am not sure if line breaks are allowed in JSON values. I certainly am unable to create the following in JSON
{"foo": "I am not sure if line breaks are
allowed in JSON values. I certainly
am unable to create the following in JSON"}
The following certainly does not work
{"foo": "I am not sure if line breaks are\nallowed in JSON values. I certainly\nam unable to create the following in JSON"}
Preamble: I want to send a long message like above either to the browser or to the console app and display it neatly formatted so it is legible to the user.
If you are displaying (or inserting) the json value directly in HTML, you can't use it as it is because in html new lines are ignored and replaced by a space.
For example if you have:
<p>Hello,
I'm in other line.</p>
It will be represented as:
Hello, I'm in other line.
You must convert the new lines to paragraph or <br>, for example:
<p>Hello,<br>
I'm in other line.</p>
That will be show as:
Hello,
I'm in other line
If this is your case, you can simply use String.replace to change \n into <br>\n.
If you're displaying it in HTML, will simple do.
Or in a text area or something, try "\r\n", wrapped in double quotes.
Double backslashes are to escape.
I'm parsing HTML page with XPath and want to grab whole text of some specific paragraph, including text of links.
For example I have following paragraph:
<p class="main-content">
This is sample paragraph with link inside.
</p>
I need to get following text as result: "This is sample paragraph with link inside", however applying "//p[#class'main-content']/text()" gives me only "This is sample paragraph with inside".
Could you please assist? Thanks.
To get the whole text content of a node, use the string function:
string(//p[#class="main-content"])
Note that this gets a string value. If you want text nodes (as returned by text()), you can do this. You need to search at all depths:
//p[#class="main-content"]//text()
This returns three text nodes: This is sample paragraph with, link and inside.