Sanskrit scripts in HTML

  1 min read
  October 03, 2020
  html sanskrit


Do you want to embed Sanksrit scripts in your HTML page? There are many ways to do this and this blog just tries to explore more on these methods and their advantages.


1. Pasting Sanskrit text directly in the HTML page.

You can do ITrans and get the Sanskrit text and paste directly in the HTML pages. There are handful of such websites online such as

Advantages

  1. There is no need for consversion
  2. Text preview works (say for blogs) works just fine

Disadvantages

  1. The amount of space the script takes (on disk) is more


2. Using Javascript to convert the English representation to Sanksrit

Write the English representation of the Sanskrit and let some JS convert this text to Sanskrit. For eg. I use this javascript to convert the below English representation to Sanskrit,

<link rel="stylesheet" href="/js/sanskrit/sanskrit.css"/>
<pre class="trans-sanskrit">
    nArAyaNam namaskrutya narancaiva narottamam|
    devim saraswatim vyAsam tato jayamudIrayet||
</pre>
<script src="/js/sanskrit/sanskrit.js"/>
nArAyaNaM namask-rtya naraM caiva narottamam|
devIM saraswatIM vyAsaM tato jayamudIrayet||

Advantages

  1. This takes less space on disk
  2. Easy to search in source

Disadvantages

  1. Need JS to convert the text, fails to work in non-Javascript environment.