I am using the free plan of the wordpress.com platform to host reference information on a small site. The goal is to be able to copy the code from the site page and place it in your own IDE, such as VSCode. Since the plan is free, all Wordpress features have been cut to a minimum, including the installation of plugins. It is possible to use only standard blocks such as HTML, Code, Classic Editor, etc. When it became necessary to publish highlighted code, I did not find anything better than to copy it from my code editor and convert it to HTML, then insert it into Wordpress standard HTML block. And for the first time everything was fine, i.e. I was able to copy a block of highlighted code from a page on my site and paste it into the VSCode code editor. And the code was displayed in the same way as on the page. But suddenly, everything changed and the following problems arose: the single quotes character (') began to display as an opening single quote (‘) and a closing single quote (’), which makes the code inoperable and needs to be edited, which is extremely inconvenient:
describe(‘Examples for Querying commands’, () => {
before(‘Navigate to querying page’, () => {
cy.visit(‘https://example.cypress.io/commands/querying‘);
});
// Скопируйте интересующий вас пример и вставьте его здесь
});
Double quotes began to display incorrectly on the site itself. Instead of ("), they began to display as (»):
cy.get(‘[data-test-id=»test-example»]’)
What could such a metamorphosis be connected with? It happened after the next resave of the edited page. The single quote character is encoded on the page as &apos replacing it with the symbol (') itself does nothing either. You can watch it here: https://kitchensinkcypress.wordpress.com/%d0%bf%d0%be%d0%b8%d1%81%d0%ba-%d1%8d%d0%bb%d0%b5%d0%bc%d0%b5%d0%bd%d1%82%d0%be%d0%b2/. The site is under construction. Please tell me how I can overcome it?
I am not sure if I can treat this as an answer, but it would be an answer if this is Wordpress bug. I found out that the reason of the issue is page update. Steps to reproduce:
Create html snippet for the highlighted code example.
Save it into html file, open the file in browser and ensure that all characters are displayed properly.
Create HTML block on the page and insert there the content of the mentioned html file.
Open the page in browser and insure that the code is displayed properly.
Copy the code snippet from the page and paste it into VSCode editor. Ensure that the code is displayed properly.
Now make any changes anywhere on the web page except of the mentioned HTML block and press Save button.
Expected result: The mentioned code snippet is still displayed properly as no changes were maid inside its HTML block.
Actual result: The snippet has been corrupted. Double quotes (") is turned into (»), single quotes are displayed as opening single quote and closing single quotes if being copied from the page and pasted to VSCode editor:
cy.get(‘[data-test-id=»test-example»]’)
which makes the code not usable. So I believe that this is a Wordpress bug as we have two different results for displaying of the same block of the html code without any user manipulation over this block.
Related
I noticed on my website, http://www.cscc.org.sg/, there's this odd symbol that shows up.
It says L SEP. In the HTML Code, it display the same thing.
Can someone shows me how to remove them?
That character is U+2028 or HTML entity code
which is a kind of newline character. It's not actually supposed to be displayed. I'm guessing that either your server side scripts failed to translate it into a new line or you are using a font that displays it.
But, since we know the HTML and UNICODE vales for the character, we can add a few lines of jQuery that should get rid of the character. Right now, I'm just replacing it with an empty space in the code below. Just add this:
$(document).ready(function() {
$("body").children().each(function() {
$(this).html($(this).html().replace(/
/g," "));
});
});
This should work, though please note that I have not tested this and may not work as none of my browsers will display the character.
But if it doesn't, you can always try pasting your text block onto http://www.nousphere.net/cleanspecial.php which will remove any special characters.
Some fonts render LS as L SEP. Such a glyph is designed for unformatted presentations of the character, such as when viewing the raw characters of a file in a binary editor. In a formatted presentation, actual line spacing should be displayed instead of the glyph.
The problem is that neither the web server nor web browser are interpreting the LS as a newline. The web server could detect the LS and replace it with <br>. Such a feature would fit well with a web server that dynamically generates HTML anyway, but would add overhead and complexity to a web server that serves file contents without modification.
If a LS makes its way to the web browser, the web browser doesn't interpret it as formatting. Page formatting is based only on HTML tags. For example, LF and CR just affect formatting of the HTML source code, not the web page's formatting (except in <pre> sections). The browser could in principle interpret LS and PS (paragraph separator) as <br> and <p>, but the HTML standard doesn't tell browsers to do that. (It seems to me like it would be a good addition.)
To replace the raw LS character with the line separation that the content creator likely intended, you'll need to replace the LS characters with HTML markup such as <br>.
This is the solution for the 'strange symbol' issue.
$(document).ready(function () {
$("body").children().each(function() {
document.body.innerHTML = document.body.innerHTML.replace(/\u2028/g, ' ');
});
})
The jquery/js solutions here work to remove the character, but it broke my Revolution Slider. I ended up doing a search replace for the character on the wp_posts tabel with Better Search Replace plugin: https://wordpress.org/plugins/better-search-replace/
When you copy paste the character from a page to the plugin box, it is invisible, but it does work. Before doing DB replaces, always have a database (or full) backup ready! And be sure to uncheck the bottom checkbox to not do a dry run with the plugin.
I purchased an email template and customized it to what I want, but now I'm stuck on how to send it.
The template file is an entire html page with included fonts and even a stylesheet at the top (styletags actually, not an attached file) with mediaqueries and some font settings.
Do I send all of that? Including header tags and more? It's basically an entire html page.
How part of my emailscript is build now:
$mail->isHTML(true);
$texts = 'html template';
$mail->msgHTML($texts);
But I haven't tested my own code yet because the template file is full of single quotes and double quotes. So the variable doesn't like that, I tried replacing all single quotes to double quotes in the templatestring but then my fonts are not working anymore (I tested remotely using this site: https://putsmail.com/).
PHPMailer itself doesn't do anything special with HTML content (though msgHTML reads your content to make a rough plain-text version). It sounds like you're just having trouble quoting inline content. You might like to try a different form of quoting called nowdoc which will tolerate all kinds of quotes without a problem:
$texts = <<<'EOT'
html template
EOT;
$mail->msgHTML($texts);
You could also save it in an external file and read it in when you need it, which also avoids quoting issues:
$mail->msgHTML(file_get_contents('template.html'));
I am getting random quotes in my HTML (see image below), and I can't for the life of me figure out how to get rid of them. I have traced it right back to my model and there are now quotes there. I have also compressed all my code and there are still quotes.
Any one had this bug???
Here's my PHP code
<ul><?php foreach ($account_media as $value) : ?><li class="span2"></li><?php endforeach; ?></ul>
I am using CodeIgniter
UPDATE: ok this is from a while ago but thought i would update you all with my solution. DO NOT COPY AND PASTE FROM JSFIDDLE really hard to debug (paste code into text editor save as plain text and then delete the old code and replace with plain text version)
Why are you using Inspect Element instead of View Source? What does View Source show?
Quotes might appear as an indication for empty in element inspection. Or in your case, it might show that <li> tags are non-blocks and are separated.
And please, people, read/write it right, I'm so sick of seeing ignitOrs. It's CodeIgnit E r. And I don't point it out just because I'm some correct terminology freak, but because it makes your questions be parsed incorrectly by search engines.
The space between <li> elements is a css issue, refer to this article: Remove Spacing between li
Chrome does this normally. It is nothing to be worried about.
View the source in the future for an absolute rendering of your HTML instead of inspecting the elements.
See screenshot below.
I have an HTML page which needs to display some HTML generated by the user on the Administration area (like a blog, for instance). The problem is that the user sometimes needs to copy-paste tables and other "garbage" content from Word/Excel to the WYSIWYG editor (that has the proper "paste from Word" function). This causes the resulting HTML code to be very dirty.
It wouldn't be a problem unless some of these pages are shown totally wrong: other divs AFTER user's HTML code are not in their supposed position, floats are not respected... etc...
I tried putting a div:
<div style="clear: both;"></div>
without success. I even tried with iFrames, but iFrames accept only external webpages (if applicable...).
The question is: is there any tag or method to put a part of an HTML code inside a webpage discarding all formatting AFTER this code?
Thank you.
To my knowledge, you simply want to end all divs. HTML is a very simple code, with very simple options. Your example doesn't work because HTML isn't that advances. You can either start a function <...> or end a function .
Ideally what you want is a piece of code that puts their work in a separate frame entirely, so as soon as the page passes their code, it goes back to the correct formatting.
Or, you could be really sloppy and put one hundred 's in, just in case.
Here's the use case: A user clicks on a link that opens a window displaying the contents of a text log. Easy enough. But is there a way of using POST, to open that text log to a certain location (i.e., search for a particular timestamp given in the post, and show the file at that specific location)?
(Assume I can't put html tags inside the text log -- it's a raw file).
Template of log:
+++ 2009/06/19 10:47:12.264 ACTION +++
+++ 2009/06/19 10:49:12.111 ACTION +++
So I want the page to load a specific timestamp.
Thanks,
Michael
Why can't you just have a php or perl or simlar script that processes the log file on the spot, and sticks in html anchors and calls it a day?
Doing on the spot processing would also allow you display a trimmed down copy of the log thats only relevant to the timespan around the event in question.
Since you can't modify the file, the only way would be to wrap it in a <frame> or an <iframe> and drive the searching and scrolling from JavaScript in the neighbouring/containing page.
Here's an example, which you can try out online at http://entrian.com/so-container.html
<html><head><script>
function go() {
// "line" is the <input> for which line to jump to; see the HTML.
var line = document.getElementById('line').value;
if (document.body.createTextRange) { // This is IE
var range = frames['log'].document.body.createTextRange();
if (range.findText(line)) {
range.select(); // Scroll the match into view and highlight it.
}
} else { // Non-IE. Tested in Firefox; YMMV on other browsers.
frames['log'].find(line); // Scroll the match into view and highlight it.
}
}
</script></head><body>
<input type='text' size='5' name='line' id='line' value='10'>
<button onclick='go()'>Go</button><br>
<iframe name='log' width='100' height='50' src='so-data.txt'>
<!-- so-data.txt contains the numbers 01-20 on separate lines -->
</body></html>
I've tested that in IE7 and FF3; I'd be surprised if it worked elsewhere without edits, but you never know your luck!
Obviously in your case you'd be driving the scrolling programmatically rather than via an <input> box, but you can see how it would work for you.
If you could put some tags around the file's text, then you could probably insert some javascript that would scroll the window after loading it.
Yes, but passing your parameters via a querystring would be a whole lot simpler.
To scroll to a certain position in the text file you will need to user javascript (overly complicated in my opinion) or add an html anchor tag.
If you were planning to post the raw text log in a window, you will also run into some difficulty as HTML will not recognize the newlines and run the log together into one blob.
have you tried
window.open ('log.txt');
window.scrollTo (0, window.scrollMaxY);
? From mozilla reference : https://developer.mozilla.org/en/DOM/window.scrollMaxY
Keep a 'living copy' of the log file that has been translated to HTML - every time the original file is modified (or simply every X seconds), check for and append the newest lines with HTML anchors applied to the HTML version.
A new feature was added to Chromium waaaaay back in 2020 that allows you to link to ANY location on any webpage.
At the time of this writing, it works for sure in Chrome and Opera but not yet in Firefox, Safari or Brave browser.
The trick is to add:
/#:~:text=
and follow the equal sign with the desired search text, replacing any spaces with %20. Example:
There is no ID near this location on the page
<div>IMPORTANT: Use Opera or Chrome to open above link</div>
For more information:
Linking to a specific part of a web page