How to use syntax highlighting in next js? - next.js

I am able to parse the markdwon with the help of remark and remark-html. How can I add syntax highlighting features for the code element?

I've been searched for TWO whole days trying to use remark/rehype ecosystem on syntax highlighting which is way more complex to use. I'm still working on searching, it's better to avoid remark/rehype ecosystem and try another method.
Here I share list of my search, just give you some subjective perspective so that you won't waste you too much time on things that not working. None of them will work as you expected, and their sample code are obscure or just broken codes.
https://github.com/remarkjs/remark-highlight.js
They move to support rehype. Are you a big fan of them wanna move as well?
https://github.com/sergioramos/remark-prism
You will get this error: Module parse failed: Unexpected character '�'
https://github.com/torchlight-api/remark-torchlight
They states on their website: 🚨 This client is still very much a work in progress. Please open issues! 🚨View it on github at github.com/torchlight-api/remark and this link is invalid.
https://github.com/rehypejs/rehype-highlight
It force you to use rehpye althought you can you remark-rehype for you to transfer easily. However, debug your code once you encounter some error will be helpless.
sample code use third-pary v-file to read file showing their code is working but not. and it reads html file not markdown file.
It's hard for you to grasp their concept to use their plugins to easily. It waste most of you valuable time to think what they think.
I give up remark/rehype ecosystem and stay away from them. Good luck! :)

Related

Trying to find a good way to convert HTML to PDF

how are you. For a while I've been working for a Gynecologist building her a data base. For the project I am using Firebase and JavaScript. The database is for her to keep track of their patients and she keeps reports on each one of them. I am almost done with the job, the UI is almost finished, the core functionalities of the database (save data, delete, retreive, and update) are up and running but I am stuck in one little thing. She asked me for a way to turn those reports she keeps in the database into a format like PDF so she can print them and give them in case needed to her patients. The thing is that Ive tried with html2pdf, a git repository that works kind of clunky, and tried looking for others but I still cant find one that works correctly. So I wanted to ask you guys if you know of some alternatives. I started thinking about using EXCEl or Word document. But either way it seems quite complicated. Thank you for your time.
Best to all.

CSS-precompiler LESS and/or SASS

Is there a way to avoid working with the command-line installing and using LESS??
There are several offers for GUIs for the compiling-phase, but I did not find a way for the Installation-Phase.
I have been working in the IT-business for so many decades (more in the mainframe and midrange area and as a project-manager and programmer in the application development) and could by now avoid to go as far down to the command-line-world.
I did develop quite fine Websites using HTML5 and CSS3 and doint this I felt a desire for all that, what LESS and/or SASS are offering and the Syntax and logics dont look difficult to handle. But I fail in the first step of just installing it.
The LESS-Website offers command-lines to key in. But I am not sure, if this will be all I have to key in, but only the significant line to be embedded in a sequence of other commands very familiar to all those working at this Level.
How do I e.g. define the place to store the Installation and to refer to in the href in the link-Statement of my html-file .... ??
Thanks
Gerhard (from Vienna/Austria, living in Trier, Germany)
Less is a CSS pre-processor. if you are include less.js in you html page
You can use less directly in to your html page.
Other ways you can use less compiler
Kola this is an open source application it will help you to compile less to css
Your Topics are clear to me. I even downloaded Koala already and I have no Problem in including less.js in my html. And I have read Bass Jobsens book about the Syntax, which does not seem to raise great Problems to me.
But before working with it, I will have to download LESS -what I have done from the Less-Website to the Folder of my choice. My Problem is the next necessary step: To install this downloaded program. There is no install.exe or something like that. The book as well as the info in the less-Website tell me to key some crpytic commands into the command-line.

PDF to HTML or similar

I'm building an application to view pdf's through a browser without the need of a plugin on mobile devices. I tried ImageMagick and ghostscript to covert the pages to images but they are far too large and text becomes unclear. I see website offering a service of converting pdf's into html and do a descent job but I can't find an example of how this is accomplished. Any help is much appreciated. Thanks!
EDIT: I seem to have read the question backwards. In this case it might be best to parse through the PDF and then format some HTML based on what you find. I believe the javapdf option is capable of this, but I haven't used any of these so I am not sure. If worse comes to worst and you can't find software to disassemble a PDF, you might be able to write your own disassembler in Java or PHP by reading the PDF specification. Best of luck!
http://www.adobe.com/devnet/pdf/pdf_reference.html - PDF Specification (Adobe Modified Version, because they are most popular you may want to support their extensions)
-- OLD -- These websites probably write their own proprietary software to do the trick. If you are truly interested in this undertaking, I would suggest parsing the HTML to get the data and style information and using it to format some sort of PDF writer APIs. A quick Google search yields the following: -- END OLD --
http://www.cutepdf.com/Solutions/
http://ruby-pdf.rubyforge.org/pdf-writer/doc/index.html
http://asprise.com/product/javapdf/
If you are looking at converting PDF to HTML and planning to run the conversion on a server, then you can try pdf2html. It is a program packaged as part of poppler-utils. I do not know how the program accomplishes it.
I was googling and came across the below link explaining how scridb.com implements conversion.
http://coding.scribd.com/2010/06/01/the-perils-of-stacking/

Where can one post nicely formatted code combined with LaTeX for mathematical expressions?

Admittedly not a programming question, but I don't really know where else to ask this...
I'm planning to start a blog to post the stuff I'm working on, which is mostly about Expression Trees & Mathematics. Hopefully this will help me focus on the problem at hand instead of going off every possible tangent that comes up.
I wonder if someone out there knows a good place to host a blog with the two following requirements:
(1) Nice support for code listings (as seen here, for example).
(2) Support for complex mathematical expressions, ideally in LaTeX (as seen here, for example).
For a while now I've been looking around for posts/articles combining both nicely formatted code and mathematical expressions, but I haven't found anything.
Thanks a lot!
PS - If there's another Q&A forum where this question would fit better, then please let me know and I'll move it there.
EDIT(1): While carrying out some additional research, I found this related SO question (see also resources therein), which then took me to here. Leaving the question open for now though in case someone wants to suggest alternatives.
Read here:
http://sixthform.info/steve/wordpress/?cat=2
http://fugato.net/2007/01/20/latex-in-wordpress/
about LaTeX on Wordpress, syntax higlighting is easy (hint: google for "syntax highlighting") and you can go on any host with WP.
Good luck.
Edit: Okay, about that latex - it seems you need to have administrator rights, so any hosting with friendly administrator or virtual server or server hosting/housing :)
Edit: As for syntax highlighting:
PHP SH: http://xtractpro.com/articles/CSharp-Syntax-Highlighter.aspx
JS SH: http://wordpress.org/extend/plugins/google-syntax-highlighter/
For math expressions in LaTeX syntax checkout MathJax. It can probably be used with most blog hosting services. You just need to be able to add javascript to the page.

Tool to merge 3 CSS files

Merging huge CSS files is huge pain,
Hi i found some question asked on the same line. I tried some of the tools but they end up merging line by line rather than on the basis or CSS rules.
Now i thought i should right one good program to do following,
1. read CSS file convert in XML
2. sort it on the basis of CSS rule
Now write one more program to consume 3 XML files find different classes and merge the files nicely based on CSS rules.
How ever that turned out to be good amount of work and i hope there must be someone who must have faced this problem before me and solved it clean way.
Please add your thoughts and suggestions, I would love to know the tool for this however i would also love to know how to design/code for this kind of tool? Am i thinking on right track ?
Thanks All,
There is a free tool called CSS Merge. Have you tried it?
Since order is important in CSS, it is difficult to merge files more sensibly than simply concatenating them. Certainly, this can't be done in the general case. In a specific case you might be able to produce a tool that can do it.

Resources