I have just installed MediaWiki in my server.
When I try to create an article on the Create Article page, all the default <div> tags are being escaped and shown as text on the page, see screenshot:
Excerpt of article HTML rendered by MediaWiki:
<div id="mw-content-text"><p><div class='noarticletext'>
There is currently no text in this page.
You can search for this page title in other pages,
How can I fix this problem?
Thanks!
Most likely because it was so minimal, you did not satisfy all the newline requirements for using <div> in a MediaWiki article. Specifically:
<div> is a generic block container. Rules:
<div> should be followed by a newline
</div> should be preceded by a newline
</div> followed by text on the same line, two newlines and text before <div> on the same line should be avoided (because the two newlines only produce a space)
From Help:HTML in wikitext, https://meta.wikimedia.org/wiki/Help:HTML_in_wikitext#.3Cdiv.3E
Recommendation
Fulfill the newline requirements, for example in MediaWiki source for that article, write:
<div class="noarticletext">
This is on a new line, fulfilling the rules, so this div should now render.
</div>
Preview or save to view the results.
Related
<div id="container">
<div class="image">< img height="500px"src="./images/image-product-desktop.jpg" alt="">
<p>PERFUMES</p>
</div>
when I add a paragraph the div breaks into two parts, please help.enter image description here
You have to properly write the html markup by opening and closing the tags. The markup you shared has 2 <div> but you only closed one of them, when that happens the html parser of the browser will automatically try to close it for you which may end up doing unexpected results.
I suggest you to use an IDE like vscode and install extensions that will help you properly format your code and identify markup errors.
Using Angular 5 and Firebase, I am storing and retrieving movie review information. When creating and editing the review, line breaks are kept (I assume using an ngModel has something to do with this). However, when retrieving the review from a reader's perspective, the ReviewComponent, the line breaks are not kept. Logging the body still shows the line breaks and using Angular's json pipe shows as text\n\ntext showing where the line breaks should be.
Here is my HTML:
<main role="main" class="container">
<p style="margin-bottom: 2rem;">{{review.body}}</p>
</main>
I have also tried span and body.
How can I keep these line breaks in the review for the reader?
HTML, in general, uses br tags to denote a new line. A plain textarea tag does not use this, it uses whatever the user's system uses to denote a new line. This can vary by operating system.
Your simplest solution is to use CSS
<main role="main" class="container">
<p style="margin-bottom: 2rem;white-space:pre-wrap;">{{review.body}}</p>
</main>
This will maintain any "white space" formatting, including additional spaces.
If you want to actually replace the newline characters with br tags you can use the following regex
<main role="main" class="container">
<p style="margin-bottom: 2rem;" [innerHTML]="review.body.replace(/(?:\r\n|\r|\n)/g, '<br>')"></p>
</main>
Edit Thanks to ConnorsFan for the heads up on replace not working with interpolation.
by using the [innerText] directive the white spaces seem to be maintained, as well as the \n new lines
e.g. <small style="display:block" [innerText]="review.body"></small>
I had a similar situation where I had HTML code like this:
<div>{{msgTitle}}</div>
And I tried putting both '\r\n' and <br> in the string msgTitle, but neither of them worked to put a newline in the text displayed on the page. This link gave me the solution:
https://github.com/angular/angular/issues/7781
Use [innerHTML]="msgTitle" instead of {{msgTitle}}.
try span but set it like that:
span
{
display : table;
}
it should helps.
Before someone whines about not using regex to parse HTML, I refer you to a previous question of mine with an elegant solution which was quickly labeled as "answered" by another question's answer whining about not using regex to parse HTML (which was eventually removed from my question): Regex: Find groups of lowercase letters between HTML tag
I am again working with epubs (in Sigil), this time cleaning up the XHTML output from InDesign CC. Different from previous ID versions, it now surrounds many objects with extra <div> tags for some kind of positioning/layout reason. I am writing my own clean CSS, so the epub is exported without generating CSS, leaving extraneous <div> tags surrounding other <div>s, sometimes containing a nested structure of unnecessary <div>s.
An example of what I'm dealing with:
<div><!--unnecessary-->
<div class="figure-box">
<h4 class="f-n"><b class="b">Figure 1.3: Foobar</b></h4>
<div><!--unnecessary-->
<div class="figure">
<img alt="foo" src="../Images/bar.jpg"/>
</div>
</div>
<p class="f-ct">This is a caption, yadda yadda.</p>
<p class="f-src">Source: Copyright blah blah.</p>
</div>
</div>
Note: <!--unnecessary--> comments are illustrative, and are not present in the actual code.
I have written this regular expression in an attempt to remove the unstyled surrounding <div> tags with some success, but I'm hoping for a more elegant solution:
^(\s*)<div>\n\s*(<div class=".+?">.+?</div>)\n\1</div>
The above string matches the outermost <div>, where I can then do a replace with \1\2 to keep the contents and also the first indent (though the indent isn't absolutely necessary).
The issue with this is that I must do a find/replace all several times in order to get at and remove all of the unnecessary <div>s that are nested.
Is this as good as it will get, or is there a solution like the one I linked to above for this purpose?
I am using Expression Engine to develop a site. I have created the page I want in a template file and now I am making use of EE's tags to make the content dynamic.
{exp:channel:entries channel="test123"}
{test123}
<div class="panel" style="margin-bottom:10px;">
<div class="paneldiv" style="background-color: red;">
hello there
</div>
</div>
{/test123}
{/exp:channel:entries}
The above code makes my DIV disappear. But if I remove the tags, the DIV shows up.
Its also worth noting that when the tags are in and I click "view rendered template" the DIV shows up.
Very strange! I've been bashing my head all day!
I believe you are using the {test123} tag incorrectly. First, I'm assuming that {test123} refers to a Channel Field within the 'test123' Channel. If so, then you simply need to remove the {/test123} ending tag, as data field tags are usually single-variable tags.
The reason your div content is disappearing is that EE is failing to process {test123} as a variable pair, and therefore it doesn't show the content within.
Markdown syntax is often convenient to write blogs and comments;
But at times it interferes with the content when you would want to write a simple html
Is there a tag / syntax that asks markdown to ignore that part like the pre html tag?
If pre works, what if the markdown part needs to include an html tag?
The original implementation of Markdown (by Gruber) and PHP Markdown don't format inside block-level HTML elements, so you can use <div>, for example:
Markdown text.
More markdown text.
<div>
Markdown ignores inside the div, you can do all sorts of crazy stuff:
Stack Overflow.
<blink>Is blink still supported?</blink>
</div>
Yet more markdown text.
Will get rendered as:
<p>Markdown text.</p>
<p>More markdown text.</p>
<div>
Markdown ignores inside the div, you can do all sorts of crazy stuff:
Stack Overflow.
<blink>Is blink still supported?</blink>
</div>
<p>Yet more markdown text.</p>
At least here on Stack Overflow, the ... <pre> HTML tag works just fine for that purpose. It also formats your text like a browser would:
This is pre-formatted, so in here I can /slash/ and *star* stuff
without issues, and [[square brackets]] [are] just brackets.