Pug error parsing body of the with expression

Pug version 3.0.0 Node version 12.16.3 Input JavaScript Values documentSchema(schema: Schema): Promise { const render = pug.compileFile(path.join(__dirname, '../templates/schema.p...

Pug version 3.0.0
Node version 12.16.3

Input JavaScript Values

  documentSchema(schema: Schema): Promise<string> {
    const render = pug.compileFile(path.join(__dirname, '../templates/schema.pug'));
    return render({ schema: schema });
  }
});

Input Pug

-  var camelToTitle = function(camel: string): string {
-    var result = camel.replace(/[/-]/g, " ");
-    result = result.replace(/([a-z0-9])([A-Z])/g, "$1 $2");
-    result = result.replace("  ", " ");
-    result = result.trim();
-    result = result.charAt(0).toUpperCase() + result.slice(1)
-    return result;
-  }
-  var formatDescription = function(description: any): string {
-    return description.replace(/[([^[]+)](([^(]+))/g, "<a href='$2'>$1</a>");
-  }

mixin asString(elem)
  | It's a string

mixin asNumber(elem)
  | It's a number

mixin asObject(elem)
  | It's an object

mixin asArray(elem)
  | It's an array

mixin asElement(elem)
  case elem.type
    when "number"
      +asNumber(elem)
    when "string"
      +asString(elem)
    when "array"
      +asArray(elem)
    default
      +asObject(elem)

mixin title(elem)
  if elem
    if elem.title
      #{elem.title}
    else if elem.id
      #{camelToTitle(elem.id)}
    else if elem["$id"]
      #{elem["$id"]}

mixin description(elem)
  if elem.description
    p(class="description")=formatDescription(elem.description)

mixin location
  h3(class="location") Schema references
  p You can use either of these formats to refer to this schema from within another schema.
  p(class="location") Schema URI
    a(href=schema.uri)= schema.uri
  if(schema.jsonSchema.id)
    p(class="location") Schema id
      b: a(href=schema.uri)= schema.jsonSchema.id

html
  head
    style(type="text/css").
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
        }
        th, td {
            padding: 10px;
        }
  body
    div(class="schema")
      h2
        +title(schema.jsonSchema)
      +description(schema.jsonSchema)
      +location
      +asElement(schema.jsonSchema)

Additional Comments

When the Pug is compiled, it throws an exception «Error parsing body of the with expression». The stack trace provides no useful information for debugging my issue. My template does not contain any «with» expressions.

I tried commenting out various parts of my Pug template to narrow down the issue but was not able to find the part of the template that is triggering this exception.

Can’t write a string value with a white space #607

Comments

clementnero commented Dec 21, 2020

Describe the bug
I can’t write a string value containing a white space.

Version of yq: 4.0.0
Operating system: mac
Installed via: release/homebrew

Command

Actual behavior

Expected behavior

Additional context
It works if there is no white space:

Thanks for your help

The text was updated successfully, but these errors were encountered:

djajcevic commented Dec 21, 2020

I’m going to figure out why. Will be posting MR soon.

dhegland commented Feb 11, 2021

I mam trying to use yq and having zero success,
including the exact symptom documented in this issue right here above.
.

PS/> yq -V
yq version 4.3.2

PS/> yq e -n ‘.test = «Hello_world!»‘
Error: Parsing expression: Lexer error: could not match text starting at 1:9 failing at 1:10.
unmatched text: «H»

mikefarah commented Feb 11, 2021

is that powershell? There’s an issue raised here #719 that I still need to look into. try using double quotes?

dhegland commented Feb 12, 2021

Thanks @mikefarah the above was indeed PowerShell.
Touche! It does work in bash. 🙂 That is very clarifying. Thanks a bunch for the pointer.
🙂 You win this round 🙂

$ yq e -n ‘.test = «Hello_world!»‘
test: Hello_world!

dhegland commented Feb 12, 2021

Here’s powershell working right
PS > yq e -n ‘.test = «»something»»‘
test: something
PS >

Thanks again for your help

sdthameem commented Jun 3, 2021 •

I am facing similar issues when using yq command in power shell.
Below is the command
PS > yq eval ‘to_entries’ sample.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
unmatched text: «to»

PS > cat sample.yaml
BU: local-market

ThibaultDelaune-pro commented Jul 1, 2021

I am facing similar issues when using yq command in power shell.
Below is the command
PS > yq eval ‘to_entries’ sample.yaml
Error: Parsing expression: Lexer error: could not match text starting at 1:1 failing at 1:3.
unmatched text: «to»

Hi, same here on Windows (Git Bash) in version 4.6.3 :

SourceTrees commented Sep 28, 2021 •

yq Version 4.11.0

@ThibaultDelaune-pro
Working in Windows GitBash:
yq e -i ‘.test = «13137»‘ values.yaml

Subpath for example folder1/values.yaml not found though had to run it from values.yaml root.

Working in Powershell Windows:
yq e -i ‘.test = «»13137″»‘ values.yaml

Subpaths are found, so you could call it form folder1/values.yaml
@sdthameem Pay attention on the double quote in Windows Powershell «»13137″»

mxchist commented Jul 14, 2022 •

Now i’m trying to use yq and having zero success.
I want bypass output of kubectl command to yq.

How is look yaml input for yq

kubectl get deployments -o custom-columns=IMAGE:. -o yaml
makes output:

yq query

kubectl get deployments -o custom-columns=IMAGE:. -o yaml | yq ‘items’ —

Actual behavior

Expected behavior

Return spec node

yq 4.25.3 from the snap, Linux Ubuntu 20.04.1

Источник

Fixing error(23, 2) Error parsing expression, misplaced: func

When I try to use the GDScript code below, Godot gives me the error:

error(23, 2) Error parsing expression, misplaced: func

Why am I getting this error, and how can I fix it? Is there another input node that could give the same results without the error?

1 Answer 1

the function that i have keeps giving me the error(23, 2) is there another input node that could give the same results without the error?

This looks like symptoms of the XY problem, you have a syntax error, but you try to change the algorithm to avoid it. You’d better ask how to fix the syntax errors.

It looks like you did not format/indent your code properly: the parser thinks you want to add a function ( _on_UFO_input_event ) to another function ( _process ), which is not allowed (highlighted by the error message Error parsing expression, misplaced : it does not expect the keyword func in the context of a function). GDScript is a lot like Python, where the indentation of the code has a significant importance.

Following the tips from this official page, you should use four spaces for your indentation.

Your code should end up looking like this.

Correctly formatting your code is required in a language such as GDScript. And it is very important with other languages in general: it allows you to read and parse what’s going on faster and more easily.

In addition, the (23,2) is not a pair of random numbers, it tells you where the issue is in your code. It tells you «at this location, I have found this error». Most IDEs allow you to double-click on the error and take you right to there in your code.

Источник

Exception thrown on compile: Error parsing body of the with expression #3277

Comments

Bikeman868 commented Jul 15, 2020 •

Pug version 3.0.0
Node version 12.16.3

Input JavaScript Values

Input Pug

Additional Comments

When the Pug is compiled, it throws an exception «Error parsing body of the with expression». The stack trace provides no useful information for debugging my issue. My template does not contain any «with» expressions.

I tried commenting out various parts of my Pug template to narrow down the issue but was not able to find the part of the template that is triggering this exception.

The text was updated successfully, but these errors were encountered:

Bikeman868 commented Jul 15, 2020

I finally figured out what causes this. The JavaScript functions were copied from my app source and are written using TypeScript. Once I removed the type information the template compiles successfully.

It would be great if the exception thrown by Pug contained something that would at least identify the part of the script that was causing a problem. Thanks.

riskoviv commented Oct 2, 2020

I encountered the same error today. The reason of that was in this part of pug file:

and that error is disappeared after I rewrote conditions to ternary operators:

rotsee commented Dec 21, 2020

More generally, it seems like this error can be caused by any syntactical error in a multiline code block.

ngdangtu-vn commented Feb 5, 2021

In my case this is cause by a typo const keyword of JavaScript. In short, this error message needs update for more detail. Too general message could cause dev ‘panik’.

Kurohyou commented Jan 4, 2022

This really needs to get fixed. At minimum, it needs a file reference when the problem is in an included pug file instead of only referencing the top most file in the include chain like it does now and a line/column number for the problem.

Источник

Error when parsing expression #872

Comments

noorbakerally commented Aug 7, 2019 •

I am getting an error when parsing the expression or . The codes and error are below. I have noticed that the error happens is from an imported ontology even if the class in the expression is in the ontology. I’m checking that they are in the ontology using containsClassInSignature

Codes for parsing expression

The text was updated successfully, but these errors were encountered:

ignazio1977 commented Aug 7, 2019

It works for me. I suspect your ontology does not have the entities you’re using. Check their namespaces.

noorbakerally commented Aug 8, 2019 •

This is the ontology i am using: http://homepages.laas.fr/nseydoux/ontologies/IoT-O.owl where i am getting the error. I forgot to precise the parse did work in cases where the entities in the expression are not from an imported ontology. I have noticed that this error raises when the entities are from an imported ontology.
For example, in the codes below, before parsing the expression, I do a check if the class is in the ontology and then i parse the expression. As you can see, the class are well in the ontology and yet the expression cannot be parsed.

noorbakerally commented Aug 19, 2019

@ignazio1977, were you able to reproduce the error with the above ontology ?
thanks

ignazio1977 commented Aug 27, 2019

There is no method to navigate the imports closure to get the result you wish, but you can work around the problem this way:

Tis will add all the declared entities to the parser structures and then still set the default ontology yo the value you need. Parsing should then work.

Источник

Exception thrown on compile: Error parsing body of the with expression #3277

Comments

Bikeman868 commented Jul 15, 2020 •

Pug version 3.0.0
Node version 12.16.3

Input JavaScript Values

Input Pug

Additional Comments

When the Pug is compiled, it throws an exception «Error parsing body of the with expression». The stack trace provides no useful information for debugging my issue. My template does not contain any «with» expressions.

I tried commenting out various parts of my Pug template to narrow down the issue but was not able to find the part of the template that is triggering this exception.

The text was updated successfully, but these errors were encountered:

Bikeman868 commented Jul 15, 2020

I finally figured out what causes this. The JavaScript functions were copied from my app source and are written using TypeScript. Once I removed the type information the template compiles successfully.

It would be great if the exception thrown by Pug contained something that would at least identify the part of the script that was causing a problem. Thanks.

riskoviv commented Oct 2, 2020

I encountered the same error today. The reason of that was in this part of pug file:

and that error is disappeared after I rewrote conditions to ternary operators:

rotsee commented Dec 21, 2020

More generally, it seems like this error can be caused by any syntactical error in a multiline code block.

ngdangtu-vn commented Feb 5, 2021

In my case this is cause by a typo const keyword of JavaScript. In short, this error message needs update for more detail. Too general message could cause dev ‘panik’.

Kurohyou commented Jan 4, 2022

This really needs to get fixed. At minimum, it needs a file reference when the problem is in an included pug file instead of only referencing the top most file in the include chain like it does now and a line/column number for the problem.

Источник

Bikeman868

Exception thrown on compile: Error parsing body of the with expression

Pug version 3.0.0
Node version 12.16.3

Input JavaScript Values

  documentSchema(schema: Schema): Promise<string> {
    const render = pug.compileFile(path.join(__dirname, '../templates/schema.pug'));
    return render({ schema: schema });
  }
});

Input Pug

-  var camelToTitle = function(camel: string): string {
-    var result = camel.replace(/[/-]/g, " ");
-    result = result.replace(/([a-z0-9])([A-Z])/g, "$1 $2");
-    result = result.replace("  ", " ");
-    result = result.trim();
-    result = result.charAt(0).toUpperCase() + result.slice(1)
-    return result;
-  }
-  var formatDescription = function(description: any): string {
-    return description.replace(/[([^[]+)](([^(]+))/g, "<a href='$2'>$1</a>");
-  }

mixin asString(elem)
  | It's a string

mixin asNumber(elem)
  | It's a number

mixin asObject(elem)
  | It's an object

mixin asArray(elem)
  | It's an array

mixin asElement(elem)
  case elem.type
    when "number"
      +asNumber(elem)
    when "string"
      +asString(elem)
    when "array"
      +asArray(elem)
    default
      +asObject(elem)

mixin title(elem)
  if elem
    if elem.title
      #{elem.title}
    else if elem.id
      #{camelToTitle(elem.id)}
    else if elem["$id"]
      #{elem["$id"]}

mixin description(elem)
  if elem.description
    p(class="description")=formatDescription(elem.description)

mixin location
  h3(class="location") Schema references
  p You can use either of these formats to refer to this schema from within another schema.
  p(class="location") Schema URI
    a(href=schema.uri)= schema.uri
  if(schema.jsonSchema.id)
    p(class="location") Schema id
      b: a(href=schema.uri)= schema.jsonSchema.id

html
  head
    style(type="text/css").
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
        }
        th, td {
            padding: 10px;
        }
  body
    div(class="schema")
      h2
        +title(schema.jsonSchema)
      +description(schema.jsonSchema)
      +location
      +asElement(schema.jsonSchema)

Additional Comments

When the Pug is compiled, it throws an exception «Error parsing body of the with expression». The stack trace provides no useful information for debugging my issue. My template does not contain any «with» expressions.

I tried commenting out various parts of my Pug template to narrow down the issue but was not able to find the part of the template that is triggering this exception.

Bikeman868

I finally figured out what causes this. The JavaScript functions were copied from my app source and are written using TypeScript. Once I removed the type information the template compiles successfully.

It would be great if the exception thrown by Pug contained something that would at least identify the part of the script that was causing a problem. Thanks.

riskoviv

I encountered the same error today. The reason of that was in this part of pug file:

mixin textField(options)
  -
    var inputClassName = "text-field__input"
    if options.isMasked
      inputClassName += " text-field__input_masked"
    if options.isForceHoverStyle
      inputClassName += " text-field__input_force-focus-hover"

and that error is disappeared after I rewrote conditions to ternary operators:

mixin textField(options)
  -
    var inputClassName = "text-field__input"
    inputClassName += options.isMasked ? " text-field__input_masked" : ""
    inputClassName += options.isForceHoverStyle ? " text-field__input_force-focus-hover" : ""

rotsee

More generally, it seems like this error can be caused by any syntactical error in a multiline code block.

ngdangtu-vn

In my case this is cause by a typo const keyword of JavaScript. In short, this error message needs update for more detail. Too general message could cause dev ‘panik’.

Kurohyou

This really needs to get fixed. At minimum, it needs a file reference when the problem is in an included pug file instead of only referencing the top most file in the include chain like it does now and a line/column number for the problem.

prodkt

I’m lost as to why this has never been addressed. This is clearly still open as I’ve encountered this myself. Am I to expect that closed tickets are really open tickets just brushed under the rug with this package?

PeterV989

I agree with @prodkt as I just encountered it myself.

m10

I’m lost as to why this has never been addressed. This is clearly still open as I’ve encountered this myself. Am I to expect that closed tickets are really open tickets just brushed under the rug with this package?

The status is «Open» since 2020. The message above is about a referencing Bug in webdiscus /
pug-loader which won’t be fixed since this is an upstream bug in pug.

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Понравилась статья? Поделить с друзьями:
  • Publisher произошла серьезная ошибка во время последнего запуска
  • Public key retrieval is not allowed dbeaver как исправить
  • Public error reporting joomla
  • Pubg память не может быть read windows 10 как исправить
  • Pubg ошибка серверы перегружены пожалуйста повторите попытку позже