From 97168547dacaeb85424522efed9ddcbae76bc668 Mon Sep 17 00:00:00 2001 From: Murukesh Mohanan <murukesh@cse.iitb.ac.in> Date: Fri, 28 Aug 2015 19:27:27 +0530 Subject: [PATCH] non-copyable line numbers --- _posts/2015-08-28-vim-for-man.md | 4 ++-- styles/posts.css | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/_posts/2015-08-28-vim-for-man.md b/_posts/2015-08-28-vim-for-man.md index 3fa7763..45072ed 100644 --- a/_posts/2015-08-28-vim-for-man.md +++ b/_posts/2015-08-28-vim-for-man.md @@ -83,7 +83,7 @@ a manpage no matter how I opened it. Hence, they should really be in Vim's filetype settings for `man`. So, I created a `~/.vim/ftplugin/man.vim`, containing: -{% highlight vim linenos %} +{% highlight vim lineanchors %} function! PrepManPager() if !empty ($MAN_PN) silent %! col -b @@ -118,7 +118,7 @@ A bit of experimentation later, I found that: Knowing that I'm reading from `stdin` and that `MAN_PN` is set (to the manpage name!), I came up with this version: -{% highlight vim linenos %} +{% highlight vim lineanchors %} " vimrc if !empty($MAN_PN) autocmd StdinReadPost * set ft=man | file $MAN_PN diff --git a/styles/posts.css b/styles/posts.css index 7aca788..74af27d 100644 --- a/styles/posts.css +++ b/styles/posts.css @@ -26,12 +26,28 @@ img { max-width: 100%; } -.linenos, .lineno { - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: -moz-none; - -o-user-select: none; - user-select: none; +/* + * From http://drewsilcock.co.uk/proper-linenumbers/ + */ + +pre { + counter-reset: line-numbering; +} + +pre a::before { + content: counter(line-numbering); + counter-increment: line-numbering; + padding-right: 1em; /* space after numbers */ + text-align: right; + opacity: 0.4; + display: inline-block; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + min-width: 1em; } @media screen and (orientation:landscape) { -- 2.24.1