Code colors in Html using CSS or javascript [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I have a website and I teach Java on it.
I know html and css if it helps..
I have lectures in my site and in my lectures there are descriptions: in the description I write code sometimes so I made a class for code so everytime I type code I do and it looks good, but not perfect.
I want to make specific words to be bold and in blue or pink color for example.
Is there a way to do it? maybe with javascript?
I know I can create a new class for special words and then to do for example but this will be too much job to write this span every time that it's not worth it.
So is there a way to do it maybe with html5 or js? Thank you.
edit: I use the usefedora.com platform so it's more difficult to do it, does somebody knows how to do it on usefedora's platform?

the thing you are searching for is a codemirror. There are many codemirrors but only one of them is called codemirror.
Code Mirror
There are also solutions that don't require you to write any javascript, using web components.
Prism.js
Here is one that's insanely trivial to use

There are plenty of code to html converters which do syntax highlighting if that's what your looking for e.g.
http://tohtml.com/java/
or
http://hilite.me/
You can take this HTML and use it on your site.

You can also download a jQuery plugin. SyntaxHighlighter is very popular.
The way they work is that you copy the files to your website, and then you just put your code into a tag, and the plugin automatically beautifies your code.

I would recommend choosing one of these libraries- PrismJS, Highlight.js, or Rainbow.
Each is designed for exactly this purpose. You just put your code into the web page, inside an HTML5 code tag decorated with the language name. They will automatically format your code with the necessary markup to attach color styles to. No need for any external tools. The first two provide their own styles as well, the last assumes you'll write your own.

Related

Javascript Library to build drag and drop interface and connect elements with line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 months ago.
Improve this question
I am looking for an approach or Javascript library that I can use to build a scientific modeling application. I suppose this is analogues to the way flowcharting software like Visio works. Add elements and connect them with click and drag.
I need to be able to define certain elements and add them to the "canvas" by selecting the element and dragging them onto the canvas.
When I click on an element I need to be able to set certain parameters for that element.
I also need to be able to connect one element to another by clicking on one and dragging a line to the second element.
I am looking for some advise on the best javascript library or approach to use. I will probably build the app in Vue.js as I have some experience using it.
Given a bit more complicated feature set, I've opted for mxgraph (the draw.io library). It's old, it's heavy, it's complicated, it's written in vanilla javascript, and to make it work with Vue you'll probably need to write the integration yourself. But it works, and there is light at the end of the tunnel.
Most important parts for me were: custom complex shape support (like, with groups, and "handles" - you know, these yellow dots you use to "adjust" some shape pieces in Visio for example), undo/redo, save/load, print.
joint.js ("rappid" now) may be my second bet if mxgraph won't cut it (not sure how it compares, but the feature list includes the items I needed)
There is also always an option to do it all with plain javascript; you have basic libraries like svg.js, snap.svg, etc that would allow that. moving shapes with drag-drop is no problem even with plain javascript. But in this case connector routing and undo/redo would be on you, and that's a bit harder.
If you find something better than these options please let me know!
btw, Visio Online does not support custom shapes at all now.

Draft-js saving and displaying HTML [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm wondering if anyone came up with any tutorial / walk through for Draft-js to simply save editor state and display it as html to the user. I've been searching and trying and still unable to display html. It seems like most are just saving the editor state and reloading it into the editor instead of displaying it as html.
It seems like most go with convertFromRaw and convertToRaw, but the amount of steps included in that seems like there are quite a few steps that should be simplified, and the example here: https://draftjs.org/docs/api-reference-data-conversion.html#content seems like it's only used to place the content back in the editor later.
Maybe I'm not even looking at the right tool - I simply want an editor to save formatted text and display it. I'm not sure why the resources are so hard to find, or if I'm just looking in the wrong spots (seems like there are too many packages for Draft-js with not much documentation and examples IMO). However, I'm sure this must not be hard to accomplish.
Draftjs is concentrating on displaying rich text within an editor. However, if you want to display the corresponding HTML you have to use an external package called draftjs-export-html.
import {stateToHTML} from 'draft-js-export-html';
you can get the html using let html = stateToHTML(editorState.getCurrentContent(), options); this will do the basic formatting of styles like bold, italic etc. You can also pass your own styling preferences of your draftjs entites using the option parameter.
https://www.npmjs.com/package/draft-js-export-html

New web to print solution [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm working on a web-shop with a personalize function. The web-shop is going to sell prints. Before customers goes to check out, they will be able to customize their product/print with just changing custom text on the designs. I know their is many different web2print solutions. I'm thinking about using Adobe's Scene7 web to print solution. It's a service and will cost money, so I rather do something more simple.
The thing is that most web2print solutions are so advanced with so many edit options. I just want to have limited rows of text to customize.
So my idea was to make the designs in html and css. With a basic background image and text on top of the background image. When the customer is done filling in the form for the text and clicks order. The web pages makes the html-css coded customised design and makes it to an image that gets mounted on high resolution printable pdf.
There is many web to pdf solutions, but the problem is that they doesn't seem to make an exact flat copy of what's shown in the design. I want this to work server side.
In my head this doesn't seem so advanced, maby i'm missing something?
I know css and html good, I can also handle javascript and some php. But i'm also open to learn new languages and programming skills to get this to work.
Thanks!
Use SVG which is the standard vector format (can be resized without loss in quality) and will look the same across implementations.

How to create a QR code reader in a HTML5 website? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I was looking for possibility to create QR code reader in my HTML5 based web page. I've done some googling and all the links point me to the mobile applications.
Please help me with some pointers as to how I can use HTML5 and JavaScript to read a QR code containing a url and then redirect the browser to that URL.
There aren't many JavaScript decoders.
There is one at http://www.webqr.com/index.html
The easiest way is to run ZXing or similar on your server. You can then POST the image and get the decoded result back in the response.
The jsqrcode library by Lazarsoft is now working perfectly using just HTML5, i.e. getUserMedia (WebRTC). You can find it on GitHub.
I also found a great fork which is much simplified. Just one file (plus jQuery) and one call of a method: see html5-qrcode on GitHub.
Reader they show at http://www.webqr.com/index.html works like a charm, but literaly, you need the one on the webpage, the github version it's really hard to make it work, however, it is possible. The best way to go is reverse-engineer the example shown at the webpage.
However, to edit and get the full potential out of it, it's not so easy. At some point I may post the stripped-down reverse-engineered QR reader, but in the meantime have some fun hacking the code.
Happy coding.
The algorithm that drives http://www.webqr.com is a JavaScript implementation of https://github.com/LazarSoft/jsqrcode. I haven't tried how reliable it is yet, but that's certainly the easier plug-and-play solution (client- or server-side) out of the two.

Need a tiny, light html editor for web [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
As the title says, I am searching a very tiny rich text editor. Every editor I've seen is big and has too many features. All I need is buttons to make text bold, italic, set the font of text, set the style to a paragraph or a heading and to add/edit links. I won't have a big library for that.
I think I will need to change it a bit. I have to integrate an image upload (already existing) as a feature to add and resize images in the content.
Thank's in advance.
Check out:
TinyEditor
TinyEditor is a simple JavaScript WYSIWYG editor that is both
lightweight (8KB) and standalone. It can easily be customized to
integrate with any website through CSS and the multitude of
parameters. It handles most of the basic formatting needs and has some
functionality built in to help keep the rendered markup as clean as
possible.
If you using bootstrap. Consider to use summernote.
Super Simple WYSIWYG Editor on Bootstrap.
http://summernote.org
It depends on what you're looking for. Do you need WYSIWYG? If not, I've had success using markitup:
http://markitup.jaysalvat.com/home/
Did you look at TinyMCE?
If you're using bootstrap try Bootstrap-WYSIWYG
How about bootstrap-editor?
It's simple and beautiful. It extends bootstrap-wysihtml5 with file-uploading feature (by using jQuery-File-Upload).

Categories