Git Product home page Git Product logo

Comments (2)

j4k0xb avatar j4k0xb commented on August 21, 2024

the parser is from https://github.com/jarek-foksa/xel/blob/b68391d2787c76ec574948d649ab6e77ecb554d9/utils/template.js, including all elements: https://github.com/jarek-foksa/xel/blob/master/elements/x-tag.js
so it doesn't make too much sense to develop some sophisticated guessing and prettifying when the source code is available
another issue is that modifying the spaces and newlines can affect the formatting (e.g. in a <pre> element)

if you still wanna do it, I suggest renaming the functions to html and css, then letting prettier handle it: playground

from webcrack.

milahu avatar milahu commented on August 21, 2024

renaming the functions to html and css

thanks! : )

#!/usr/bin/env bash

s=""

mangled_html="un"
mangled_css="xn"

# rename tagged template literals to html`...` and css`...`
# so prettier can prettify the string contents
# \b = word boundary   
s+='s/\b'$mangled_html'`/html`/g;'
s+='s/\b'$mangled_css'`/css`/g;'

# rename the tag functions to html and css
s+='s/let '$mangled_html' =/let html =/g;'
s+='s/let '$mangled_css' =/let css =/g;'

# replace html`${'str'}` with html`str`
# \b = word boundary
s+="s/\bhtml\`\\\$\{'([^'\`]*)'\}\`;/html\`\1\`;/g;"

sed -i -E "$s" elements/apps/bx-progressivewebapp.js

prettier -w \
  elements/apps/bx-progressivewebapp.js \

from webcrack.

Related Issues (20)

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.

  • 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.

  • 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.

  • D3 photo D3

    Data-Driven Documents codes.