Unwanted asterisks appearing in noweb html output - noweb

I'm getting asterisks appearing before each documentation section in my noweb html output (even before the html doctype!) when running noweave -html -index -n hello.nw > hello.htm given the following hello.nw file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Hello noweb</title>
</head>
<body>
<h1>Noweb test</h1>
<p>A noweb hello world.
<<main.c>>=
<<Includes>>
<<Defines>>
<<Main function>>
#
<h2>The main function</h2>
<p>Blablabla...</p>
<<Main function>>=
int main() {
printf("Hello %s!\n", NAME);
return MEANING_OF_LIFE;
}
#
<h2>Preprocessor stuff</h2>
<p>Blablabla...</p>
<<Defines>>=
#define NAME "John Doe"
# %def NAME
<<Includes>>=
#include <stdio.h>
# %def printf
<<Defines>>=
#define MEANING_OF_LIFE 42
# %def MEANING_OF_LIFE
<p>Blablabla...</p>
<h2>Chunks</h2>
<nowebchunks>
<h2>Index</h2>
<nowebindex>
</body>
</html>
Here's the output (note the asterisk appearing before the doctype!?):
<!-- this file was generated automatically by noweave; better not edit it-->
<a name="NWD1">*</a><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Hello noweb</title>
</head>
<body>
<h1>Noweb test</h1>
<p>A noweb hello world.
<pre><a name="NWiMOLW-1ezWyf-1" href="#NWD1"><dfn><main.c>=</dfn></a></pre><blockquote>This code is written to a file (or else not used).<p>
<a name="NWiMOLW-1ezWyf-1-u1" href="#NWD4"><i><Includes></i></a>
<a name="NWiMOLW-1ezWyf-1-u2" href="#NWD3"><i><Defines></i></a>
<a name="NWiMOLW-1ezWyf-1-u3" href="#NWD2"><i><Main function></i></a>
</blockquote><p>
<a name="NWD2">*</a><h2>The main function</h2>
<p>Blablabla...</p>
<pre><a name="NWiMOLW-32ejEQ-1" href="#NWD2"><dfn><Main function>=</dfn></a>
int main() {
printf("Hello %s!\n", NAME);
return MEANING_OF_LIFE;
}
</pre><blockquote>Used above.<p>
</blockquote><p>
<a name="NWD3">*</a><h2>Preprocessor stuff</h2>
<p>Blablabla...</p>
<pre><a name="NWiMOLW-1K8SOW-1" href="#NWD3"><dfn><Defines>=</dfn></a>
#define NAME "John Doe"
</pre><blockquote>Defines <code>NAME</code> (links are to index).<p>
Used above; next definition.<p>
</blockquote><p>
<a name="NWD4">*</a>
<pre><a name="NWiMOLW-ZKEBO-1" href="#NWD4"><dfn><Includes>=</dfn></a>
#include <stdio.h>
</pre><blockquote>Defines <code>printf</code> (links are to index).<p>
Used above.<p>
</blockquote><p>
<a name="NWD5">*</a>
<pre><a name="NWiMOLW-1K8SOW-2" href="#NWD3"><dfn><Defines>+=</dfn></a>
#define MEANING_OF_LIFE 42
</pre><blockquote>Defines <code>MEANING_OF_LIFE</code> (links are to index).<p>
Used above; previous definition.<p>
</blockquote><p>
<p>Blablabla...</p>
<h2>Chunks</h2>
<ul>
<li><i><Defines></i>: U1, D2, D3
<li><i><Includes></i>: U1, D2
<li><i><Main function></i>: U1, D2
<li><i><main.c></i>: D1
</ul>
<a name="NWD6">*</a><h2>Index</h2>
<ul>
<li><a name="NWI-MEANING_OF_LIFE" href="#NWD5">MEANING_OF_LIFE</a>: U1, U2, D3
<li><a name="NWI-NAME" href="#NWD3">NAME</a>: U1, U2, D3
<li><a name="NWI-printf" href="#NWD4">printf</a>: U1, D2
</ul>
</body>
</html>
This only happens when indexing is turned on, also it happens only when I start the doc section with a html tag. It doesn't seem to happen at all when running the same command on the wc example here (https://www.cs.tufts.edu/~nr/noweb/examples/wc.nw.html) but I can't figure out what I'm doing wrong.

Related

Hard time writing a simple code on jscript

I have hard time with this simple jscript for no reason. this code should display the time once clicked. but i get the error below. what am i doing wrong
{
"message": "Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')",
"filename": "https://stacksnippets.net/js",
"lineno": 30,
"colno": 43
}
function item(name)
{
var d = new Date();
document.getElementById("but1").innerHTML = d;
}
<!DOCTYPE html>
<html>
<body>
<script src="C:\Users\kalyanasundar.s\OneDrive - HCL Technologies Ltd\Desktop\proj\animation\index.Js"></script>
<h2>JavaScript Statements</h2>
<p id="demo">You cannot break a code line with a \ backslash.</p>
<button onclick="item(name)">Try it</button>
</body>
</html>
This id (#but1) does not exist, so innerHtml won't work, try changing it.
function item(name) {
var d = new Date();
document.getElementById("demo").innerHTML = d;
}
<!DOCTYPE html>
<html>
<body>
<script src="C:\Users\kalyanasundar.s\OneDrive - HCL Technologies Ltd\Desktop\proj\animation\index.Js"></script>
<h2>JavaScript Statements</h2>
<p id="demo">You cannot break a code line with a \ backslash.</p>
<button onclick="item(name)">Try it</button>
</body>
</html>

erlang n2o render get <span id=&quot

I want to write web with n2o and rebar3.
but I get the page something wrong ,code is here.
index.erl
-module(index).
-compile(export_all).
-include_lib("n2o/include/wf.hrl").
-include_lib("nitro/include/nitro.hrl").
main() -> #dtl{file="prod",app=web, ext="dtl", bindings=[{body,body()} ]}.
body() ->
[ #span { id=display }, #br{},
#span { body="Login: " }, #textbox{id=user,autofocus=true}, #br{},
#span { body="Join/Create Feed: " }, #textbox{id=pass},
#button { id=loginButton, body="Login",postback=login,source=[user,pass]} ].
prod.dtl
<html >
<head>
<title>{{title}}</title>
</head>
<body>
{{body}}
</body>
</html>
I get the result :
<html >
<head>
<title></title>
</head>
<body>
<span id="display"></span><br/><span>Login: </span><input id="user" type="text" autofocus="true"/><br/><span>Join/Create Feed: </span><input id="pass" type="text"/><button id="loginButton" type="button">Login</button>
</body>
</html>
how can i get get '<' not '&lt'
erlydtl enabled auto escaping of the values inside {{}} in this commit (also see #80 and #120). If you're using a version that includes this commit (from the page it looks like 0.9.0 or later), you'll have to manually mark the value as safe.
Instead of:
{{ body }}
do:
{{ body | safe }}
Note: You should be aware of the risks of marking an untrusted string as safe: https://en.wikipedia.org/wiki/Cross-site_scripting.

How to change something dynamically in the main handlebars skeleton?

I am using handelbars as my templating engine and I am curious to whether I could edit the main handlebars file. What I can do at the moment is something like this:
main.handlebars:
<html>
<head>
</head>
<body>
<div id='headerBox></div>
<div id='contents'>{{{body}}}</div><!--all contents goes here-->
</body>
When I use this method I will could create templates e.g. home.handlebars etc.
But what If I wanted to change something dynamically in the main.handlebars? For example in my website, I would love to have a login form so I would like to have something like this in the main.handelbars:
<html>
<head>
</head>
<body>
<div id='headerBox>{{If logged in print name, if not print sign up}}</div>
<div id='contents'>{{{body}}}</div><!--all contents goes here-->
</body>
</html>
TLDR, how to I change something dynamically in the main handlebars skeleton.
Thanks!
You'll want to write a Handlebars Helper function. Since you didn't include anything about how you're verifying login, I'll write a little demo.
In your template file:
<div id='headerBox'>{{header}}</div>
Handlerbars.registerHelper('header', function() {
if (loggedIn) {
return //however you're getting a username
} else {
return Sign Up
}
});

using this when including in php

in for example magento they have php seperated from phtml.
I also do the same thing.
But I can't figure one thing out, and that is:
When I have this php script:
class aclass extends main{
public function redirect(){
require_once($this->frontend_folder . $this->admin_folder . "beheer/edit_account.phtml");
}
public function nav_menu(){
return "<nav>some nav menu things in here</nav>";
}
and the "view" phtml script:
<!doctype html>
<html>
<head>
</head>
<body>
<div id="wrap">
<?php
echo $this->nav_menu();
?>
</div>
</html>
"$this" doesn't work, but how can I get this working?
you need to instantiate the class in the view.
<!doctype html>
<html>
<head>
</head>
<body>
<div id="wrap">
<?php
$c = new aclass; // instantiate the class
echo $c->nav_menu(); // run the function from the class
$c = null; // null the variable, maybe help garbage collection...
?>
</div>
</html>
this is not an optimal way to use it, but I hope the idea is clear.
EDIT: This is a simple solution, depending on your archetecture, you can do many things. In simpliest form, you should consider instantiating your class at the top of the view, then you can reference it by the handle you assign it to throughout the view.

Sitemesh layout doesn't work with g.include tag in Grails

I am rendering a view that combines a g.include invocation and a sitemesh layout.
The view would be something like this:
myview.gsp
<html>
<head>
<meta name="layout" content="checkout" />
</head>
<body>...
within the body there is an invocation to:
g.include(controller:"mycontroller", action:"myaction")
The problem is the sitemesh layout is never applied. If I remove the include invocation things work just fine.
I haven't found references to this problem in the site yet.
Has anyone found a workaround to this issue or a tip, will be much appreciated!
Thanks
-Pablo Duranti
My index file is like underlying:
<html>
<head>
<title>App Store For Publish, Download Android Apps</title>
<meta name="layout" content="main" />
<parameter name="sideBarSetting" value="main"/>
</head>
<body>
<g:if test="${flash.message}">
<div class="message">${flash.message}</div>
</g:if>
<g:announcements/>
<g:include controller="cache" action="showFeatured"/>
<g:include controller="cache" action="latestProducts"/>
<div class="push"></div>
<g:include controller="cache" action="mostPopular"/>
<div class="push"></div>
<g:include controller="cache" action="allCategories"/>
</body>
It works in Grails 1.0, 1.2.2 and now 1.3.7.
In each of actions you try to include, you can not render the view, but render the template instead. The template file can ONLY has fragments of HTML, it can NOT include the head, meta for layout, etc.
In my cache controller
def latestProducts = {
cache shared:true, validFor: 300
def htmlCacheManager = HtmlCacheManager.getInstance()
def key = 'latestProducts'
def content = htmlCacheManager.getHtmlContent(key)
if (!content) {
def products = productService.get5LatestProducts(params)
if (products){
content = g.render(template:'/common/product/productLatestListTemplate', model:['productInstanceList' : products, 'type':'latest'])
htmlCacheManager.store(key, content, Boolean.TRUE)
} else {
log.debug('No latest product found')
}
}
render content ?: ''
}
The template file:
<div class="list">
<fieldset>
<legend><g:message code="product.latest"/> <g:link action="feed" controller="product" params="['type':type]" target="_blank"><img src="${resource(dir:'images', file:'feed-icon.gif')}" height='16' width='16' alt="Feeds"/></g:link></legend>
<g:each in="${productInstanceList}" var="product">
<div class="product">
<g:render template="/common/product/productSingleListTemplate" model="['product':product]" />
</div>
</g:each>
</fieldset>
</div>

Resources