I'm quite new to Quarto and still try to figure basic things out.
Is there a way to run or echo HTML code chunks in Quarto?
This does not work:
{html}
#| echo: false
<html>
<head>
<title>
Test
</title>
</head>
<body>
<h1>Title</h1>
</body>
</html>
So what is the correct way to do it (if it's possible at all)?
EDIT: This works, but only for echo.
``` html
Test
```
Can I run the code instead and embed the result into the PDF file as a static image? Is there an automatic way to do this?
Kind regards
winnewoerp
Related
I have a very simple code but when I go running it in chrome it's blank. Other files work fine. I do not know what to do;
Move the Title inside Head
and Close the tag.
If still doesn't work, refer following code:
<!DOCTYPE html>
<html>
<head>
<title>Future Technologies: Asteroid Mining</title>
</head>
<body>
<p>Asetroid Mining</p>
</body>
</html>
Does not perform this operation. When you run the code, the program outputs a blank page, and should display Hello, World !. Please correct the error!
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body> Hello, World! </body>
</html>
The quotes around top in cannot be the "Microsoft specific" quotes.
This: "_top" works
This: “_top” fails
Just copy and past your html file as it is. There is nothing wrong with your html tags, everything is working fine and up to mark.
After seeing your question I am impatient to know about that how you create your html file?
Can anyone tell me why special here?
<html>
<head>
<script src="editor.js"></script>
</head>
<body>
<div id="scripts" class="scripts">
Editor.Execute('<html>Html String</html>');
Editor.Execute('<something>Html String</something>');
</div>
</body>
</html>
document.getElementById("scripts").innerHTML shows something however html dissapears.
Execute('Html String');
Execute('<something>Html String</something>');
It behaves the same way in Firefox and Chrome.
You're running into this issue.
Basically, the browser sanitizes out the HTML tags before your JavaScript can even access the page – you can check in the Chrome elements inspector, your <html> tag is not there.
I guess the answer depends on what exactly you're trying to do, but if you're just trying to output that code onto a web page, you can just escape the characters:
<html>
<body>
<div id="scripts" class="scripts">
Execute('<html>Html String</html>');
Execute('<something>Html String</something>');
</div>
</body>
</html>
Then document.getElementById('scripts').innerHTML will output:
Execute('<html>Html String</html>');
Execute('<something>Html String</something>');
And then you can replace the HTML entities in JavaScript.
Without knowing what you do in that Execute() it is hard to say what is going on there.
Just in case: HTML document can have one and only one <html> node.
I am using Sublime Text 2 to write my testing html file. I save the text as HTML format.
Then when I try to open the file with browser by either drag&drop or Open_With...
Then.....
The browser open my plain text file, not the actual html.
This is what it look like. Just white background and these text.
<!DOCTYPE html>
<head>
<title>A Hello World Page</title>
</head>
<body>
<p>Hello World</p>
</body>
This is my first time with html ever, do I have to do special setup with anything? I just use default SublimeText2.
That may be because you are missing the main tag <html>.
Do this:
<!DOCTYPE html>
<html>
<head>
<title>A Hello World Page</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>
<html> is the main tag, browser will look for to tell whether it is html or not.
Also make sure it is saved as .html or .htm
Open up Sublime Text, press CTRL SHIFT + P.
Type in HTML into the box and select Set syntax: HTML.
Then, in the file, type in html then press tab straight after and it should create a snippet (which is default):
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
Then make sure you save the document as .html or .htm.
This should work in your browser after.
Note: Setting syntax and doing snippet wont actually 'help' in terms of this question, but will help you in HTML by making things quicker and having syntax highlighting.
I have a variable (ex. $content) with HTML code (without line breaks - removed before). How to process HTML code with adding TAB indent after each open tag and decrease indent level after each closing tag?
P.S. I don't need external script or programm (like tidy). I need to make this in my own script.
For example:
source content:
<!DOCTYPE html><html><head><title>test</title></head> <body> <h1>hello!</h1><p>It works!</p></body></html>
needed result:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<h1>hello!</h1>
<p>It works!</p>
</body>
</html>
use HTML::HTML5::Parser qw();
use HTML::HTML5::Writer qw();
use XML::LibXML::PrettyPrint qw();
print HTML::HTML5::Writer->new(
start_tags => 'force',
end_tags => 'force',
)->document(
XML::LibXML::PrettyPrint->new_for_html(
indent_string => "\t"
)->pretty_print(
HTML::HTML5::Parser->new->parse_string(
'<!DOCTYPE html><html><head><title>test</title></head> <body> <h1>hello!</h1><p>It works!</p></body></html>'
)
)
);
<!DOCTYPE html><html>
<head>
<title>test</title>
</head>
<body>
<h1>hello!</h1>
<p>It works!</p>
</body>
</html>
The manual page says that tidy won't produce output that contains tabs. But it's simple enough to post-process the output to deal with that.
$ tidy -indent foo.html | perl -pe 's|^( +)|"\t" x ((length $1) / 2)|e;'
Using an existing tool has to be a far better solution than inventing it yourself. But if you insist then you should, at least, use a pre-written parser like Perl's HTML::Parser.
I should also point out that your specification of the problem seems to be incorrect. You say you want to add a tab after each opening tag. But your sample output doesn't do that for the <title>, <h1> or &p> tags.
An option I've used is CGI::Pretty.
You could also try Marpa::R2::HTML referring to the source of its companion/demo utility html_fmt to see how to target specific parts of the document for manipulation. I haven't used it and can't try today for want of 5.10 but it looks like it could be a good match.