Editing MediaWiki pages

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Editing MediaWiki pages

Raghavendra Nyshadham
I have recently started contributing to a Wiki that runs on MediaWiki.
I have been writing on the Web interface of the Wiki, which is
convenient for previewing, but is otherwise inconvenient.  I would like
to edit the Wiki pages from Emacs.  I found two packages for this:

1. wikipedia-mode,
   https://en.wikipedia.org/wiki/Wikipedia:Wikipedia-mode.el

2. mediawiki-el, https://github.com/hexmode/mediawiki-el

I would appreciate any advice or recommendations about these or other
packages for editing MediaWiki pages with Emacs.

Thanks and regards,
Raghu.

--
N. Raghavendra <[hidden email]>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/

Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Sharon Kimble-2
"N. Raghavendra" <[hidden email]> writes:

> I have recently started contributing to a Wiki that runs on MediaWiki.
> I have been writing on the Web interface of the Wiki, which is
> convenient for previewing, but is otherwise inconvenient.  I would like
> to edit the Wiki pages from Emacs.  I found two packages for this:
>
> 1. wikipedia-mode,
>    https://en.wikipedia.org/wiki/Wikipedia:Wikipedia-mode.el
>
> 2. mediawiki-el, https://github.com/hexmode/mediawiki-el
>
> I would appreciate any advice or recommendations about these or other
> packages for editing MediaWiki pages with Emacs.
Hi Raghu, sorry for not replying sooner but I've had the builders in and
am only now getting sorted out.

I regularly write 'articles' for my 'DrugFacts' mediawiki, using
org-mode exported as mediawiki. Every article and menu on that site is
written in org-mode, except for the top drop-down menu, and the articles
are also stored in mediawiki format in my ~/.emacs.d/wiki' directory.
Because my main file for DrugFacts is 3.4mb, I highlight the section
that I want to export and then export it as mediawiki, so that in the
mediawiki buffer I'm only left with the correct section and nothing
else. But it does require rereading and then various things like
citations being sorted out, for which I use several yasnippets further
down this email.

--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC emacs-lisp
(require 'mediawiki)
;;(require 'ox-mediawiki)
(eval-after-load "org" '(require 'ox-mediawiki nil t))
(global-set-key (kbd "M-s-a") 'org-mw-export-to-mediawiki) ;; ("mw" file)
(global-set-key (kbd "M-s-e") 'org-mw-export-as-mediawiki) ;; (temporary buffer)
#+END_SRC
[2017-03-16 Thu 10:30]

#+BEGIN_SRC emacs-lisp
(defun mediawiki-test-suite ()
  (toggle-truncate-lines 0)
  (abbrev-mode 1)
  (set-fill-column 65000)
  (auto-fill-mode 0))

(add-hook 'mediawiki-mode-hook #'mediawiki-test-suite)
#+END_SRC
[2017-03-17 Fri 21:04]

#+BEGIN_SRC emacs-lisp
  ;; do this in a hook because mediawiki-mode resets its keybindings on
  ;; evey mode change.
  (add-hook 'mediawiki-mode-hook
            (lambda ()
              (define-key mediawiki-mode-map (kbd "C-x C-s") 'save-buffer)))
#+END_SRC
[2017-04-12 Wed 15:19]
--8<---------------cut here---------------end--------------->8---

I've also set up several yasnippets which I find very useful when I'm
writing org-mode2mediawiki test, and they are -

--8<---------------cut here---------------start------------->8---
# -*- mode: snippet -*-
# name: category
# key: medcas
# --
[[Category:

# -*- mode: snippet -*-
# name: citation
# key: cref
# --
<ref name="$0"> </ref>

# -*- mode: snippet -*-
# name: citation repeat
# binding: M-s-8
# --
<ref name="$0"/>

# -*- mode: snippet -*-
# name: mediawiki-end
# key: medend
# --
----

== References ==

<references />

<span id="BackToTop"></span>
<div class="noprint" style="background-color:#fc3; color:#d33; position:fixed; bottom:2%; left:0.25%; padding:0; margin:0;">
[[#top| '''Back to the Top''' ]]
</div>
<span id="BackToTop"></span>
<div class="noprint" style="background-color:#fc3; color:#d33; position:fixed; bottom:2%; right:0.25%; padding:0; margin:0;">
[[#top| '''Back to the Top''' ]]
</div>
--8<---------------cut here---------------end--------------->8---

I hope that these have been helpful, and if I can help you further,
please, get in contact.

Thanks
Sharon.
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk 
Debian 9.2, fluxbox 1.3.5-2, emacs 25.3.2, org-mode 9.1.1

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Raghavendra Nyshadham
Dear Sharon,

Thanks for the message. I am sorry for the delay in replying; I am traveling.

The Wiki I am writing in is a  multiuser one, where users edit pages with tools of their choice.  Therefore, maintaining local versions of the pages in Org mode, and exporting from them, is not feasible.

Regards,
Raghu.

--
N. Raghavendra <[hidden email]>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/

> On 30-Oct-2017, at 14:56, Sharon Kimble <[hidden email]> wrote:
>
> "N. Raghavendra" <[hidden email]> writes:
>
>> I have recently started contributing to a Wiki that runs on MediaWiki.
>> I have been writing on the Web interface of the Wiki, which is
>> convenient for previewing, but is otherwise inconvenient.  I would like
>> to edit the Wiki pages from Emacs.  I found two packages for this:
>>
>> 1. wikipedia-mode,
>>   https://en.wikipedia.org/wiki/Wikipedia:Wikipedia-mode.el
>>
>> 2. mediawiki-el, https://github.com/hexmode/mediawiki-el
>>
>> I would appreciate any advice or recommendations about these or other
>> packages for editing MediaWiki pages with Emacs.
>
> Hi Raghu, sorry for not replying sooner but I've had the builders in and
> am only now getting sorted out.
>
> I regularly write 'articles' for my 'DrugFacts' mediawiki, using
> org-mode exported as mediawiki. Every article and menu on that site is
> written in org-mode, except for the top drop-down menu, and the articles
> are also stored in mediawiki format in my ~/.emacs.d/wiki' directory.
> Because my main file for DrugFacts is 3.4mb, I highlight the section
> that I want to export and then export it as mediawiki, so that in the
> mediawiki buffer I'm only left with the correct section and nothing
> else. But it does require rereading and then various things like
> citations being sorted out, for which I use several yasnippets further
> down this email.
>
> --8<---------------cut here---------------start------------->8---
> #+BEGIN_SRC emacs-lisp
> (require 'mediawiki)
> ;;(require 'ox-mediawiki)
> (eval-after-load "org" '(require 'ox-mediawiki nil t))
> (global-set-key (kbd "M-s-a") 'org-mw-export-to-mediawiki) ;; ("mw" file)
> (global-set-key (kbd "M-s-e") 'org-mw-export-as-mediawiki) ;; (temporary buffer)
> #+END_SRC
> [2017-03-16 Thu 10:30]
>
> #+BEGIN_SRC emacs-lisp
> (defun mediawiki-test-suite ()
>  (toggle-truncate-lines 0)
>  (abbrev-mode 1)
>  (set-fill-column 65000)
>  (auto-fill-mode 0))
>
> (add-hook 'mediawiki-mode-hook #'mediawiki-test-suite)
> #+END_SRC
> [2017-03-17 Fri 21:04]
>
> #+BEGIN_SRC emacs-lisp
>  ;; do this in a hook because mediawiki-mode resets its keybindings on
>  ;; evey mode change.
>  (add-hook 'mediawiki-mode-hook
>            (lambda ()
>              (define-key mediawiki-mode-map (kbd "C-x C-s") 'save-buffer)))
> #+END_SRC
> [2017-04-12 Wed 15:19]
> --8<---------------cut here---------------end--------------->8---
>
> I've also set up several yasnippets which I find very useful when I'm
> writing org-mode2mediawiki test, and they are -
>
> --8<---------------cut here---------------start------------->8---
> # -*- mode: snippet -*-
> # name: category
> # key: medcas
> # --
> [[Category:
>
> # -*- mode: snippet -*-
> # name: citation
> # key: cref
> # --
> <ref name="$0"> </ref>
>
> # -*- mode: snippet -*-
> # name: citation repeat
> # binding: M-s-8
> # --
> <ref name="$0"/>
>
> # -*- mode: snippet -*-
> # name: mediawiki-end
> # key: medend
> # --
> ----
>
> == References ==
>
> <references />
>
> <span id="BackToTop"></span>
> <div class="noprint" style="background-color:#fc3; color:#d33; position:fixed; bottom:2%; left:0.25%; padding:0; margin:0;">
> [[#top| '''Back to the Top''' ]]
> </div>
> <span id="BackToTop"></span>
> <div class="noprint" style="background-color:#fc3; color:#d33; position:fixed; bottom:2%; right:0.25%; padding:0; margin:0;">
> [[#top| '''Back to the Top''' ]]
> </div>
> --8<---------------cut here---------------end--------------->8---
>
> I hope that these have been helpful, and if I can help you further,
> please, get in contact.
>
> Thanks
> Sharon.
> --
> A taste of linux = http://www.sharons.org.uk
> TGmeds = http://www.tgmeds.org.uk
> DrugFacts = https://www.drugfacts.org.uk 
> Debian 9.2, fluxbox 1.3.5-2, emacs 25.3.2, org-mode 9.1.1
Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Narendra Joshi
In reply to this post by Sharon Kimble-2
Sharon Kimble <[hidden email]> writes:

> #+BEGIN_SRC emacs-lisp
> (require 'mediawiki)
> ;;(require 'ox-mediawiki)
> (eval-after-load "org" '(require 'ox-mediawiki nil t))
> (global-set-key (kbd "M-s-a") 'org-mw-export-to-mediawiki) ;; ("mw" file)
> (global-set-key (kbd "M-s-e") 'org-mw-export-as-mediawiki) ;; (temporary buffer)
> #+END_SRC
> [2017-03-16 Thu 10:30]
>
> #+BEGIN_SRC emacs-lisp
> (defun mediawiki-test-suite ()
>   (toggle-truncate-lines 0)
>   (abbrev-mode 1)
>   (set-fill-column 65000)
>   (auto-fill-mode 0))
>
> (add-hook 'mediawiki-mode-hook #'mediawiki-test-suite)
> #+END_SRC
> [2017-03-17 Fri 21:04]
How do you insert these code blocks that get syntax highlighted in Emacs/Gnus?

Best,
--
Narendra Joshi

Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Sharon Kimble-2
Narendra Joshi <[hidden email]> writes:

> Sharon Kimble <[hidden email]> writes:
>
>> #+BEGIN_SRC emacs-lisp
>> (require 'mediawiki)
>> ;;(require 'ox-mediawiki)
>> (eval-after-load "org" '(require 'ox-mediawiki nil t))
>> (global-set-key (kbd "M-s-a") 'org-mw-export-to-mediawiki) ;; ("mw" file)
>> (global-set-key (kbd "M-s-e") 'org-mw-export-as-mediawiki) ;; (temporary buffer)
>> #+END_SRC
>> [2017-03-16 Thu 10:30]
>>
>> #+BEGIN_SRC emacs-lisp
>> (defun mediawiki-test-suite ()
>>   (toggle-truncate-lines 0)
>>   (abbrev-mode 1)
>>   (set-fill-column 65000)
>>   (auto-fill-mode 0))
>>
>> (add-hook 'mediawiki-mode-hook #'mediawiki-test-suite)
>> #+END_SRC
>> [2017-03-17 Fri 21:04]
> How do you insert these code blocks that get syntax highlighted in Emacs/Gnus?
Both of these blocks came from my emacs init file, in my case an
org-file, and they then are able to be used as required.

Does this help?

Thanks
Sharon.
--
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk 
Debian 9.2, fluxbox 1.3.5-2, emacs 25.3.2, org-mode 9.1.1

signature.asc (847 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Emanuel Berg-4
Sharon Kimble wrote:

>> How do you insert these code blocks that get
>> syntax highlighted in Emacs/Gnus?
>
> Both of these blocks came from my emacs init
> file, in my case an org-file, and they then
> are able to be used as required.
>
> Does this help?

I'm pretty sure he meant the begin/end block
around the source so that Gnus shows the code
with font lock as would a regular .el file only
still in article mode...

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Raghavendra Nyshadham
In reply to this post by Narendra Joshi
At 2017-11-15T00:38:30+05:30, Narendra Joshi wrote:

> Sharon Kimble <[hidden email]> writes:
>
>> #+BEGIN_SRC emacs-lisp
>> ...
> How do you insert these code blocks that get syntax highlighted in
> Emacs/Gnus?

In Message mode, hence while composing a message in Gnus, you can use
`message-mark-inserted-region', bound, by default, to `C-c M-m'.  See
the Info node (message) > Commands > Insertion.

Raghu.

--
N. Raghavendra <[hidden email]>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/

Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Tomas Zerolo
In reply to this post by Emanuel Berg-4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Nov 15, 2017 at 05:09:34PM +0100, Emanuel Berg wrote:

> Sharon Kimble wrote:
>
> >> How do you insert these code blocks that get
> >> syntax highlighted in Emacs/Gnus?
> >
> > Both of these blocks came from my emacs init
> > file, in my case an org-file, and they then
> > are able to be used as required.
> >
> > Does this help?
>
> I'm pretty sure he meant the begin/end block
> around the source so that Gnus shows the code
> with font lock as would a regular .el file only
> still in article mode...

Those BEGIN_SRC/END_SRC are standard org-mode markup for
source code blocks.

Cheers
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAloMb5AACgkQBcgs9XrR2kYdBQCfQijPIFAT+kBORU7f3AbXBgET
B6gAn0DiRMutPjFGY1Ci2gRuHoZ1a8wO
=sx0P
-----END PGP SIGNATURE-----

Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Emanuel Berg-4
t wrote:

> Those BEGIN_SRC/END_SRC are standard org-mode
> markup for source code blocks.

org-mode! That explains why I never used them.

Actually I think it is overkill to have font
lock in mails/posts. Only single functions or
short pieces of code should be posted anyway,
and then it isn't really necessary.

If it is longer than that just use an URL so
the audience can get the file and assess it
with their own tools in good order...

--
underground experts united
http://user.it.uu.se/~embe8573


Reply | Threaded
Open this post in threaded view
|

Re: Editing MediaWiki pages

Raghavendra Nyshadham
In reply to this post by Tomas Zerolo
At 2017-11-15T17:47:12+01:00, [hidden email] wrote:

> On Wed, Nov 15, 2017 at 05:09:34PM +0100, Emanuel Berg wrote:
>> Sharon Kimble wrote:
>>
>> >> How do you insert these code blocks that get
>> >> syntax highlighted in Emacs/Gnus?
>> >
>> > Both of these blocks came from my emacs init
>> > file, in my case an org-file, and they then
>> > are able to be used as required.
>> >
>> > Does this help?
>>
>> I'm pretty sure he meant the begin/end block
>> around the source so that Gnus shows the code
>> with font lock as would a regular .el file only
>> still in article mode...
>
> Those BEGIN_SRC/END_SRC are standard org-mode markup for
> source code blocks.

Yes, but I don't know if that's relevant to the highlighting of these
blocks in Gnus, which was what Narendra asked about.

The source code blocks in Sharon's message are enclosed between the
strings

"--8<---------------cut here---------------start------------->8---\n"

and

"--8<---------------cut here---------------end--------------->8---\n",

which are the default values of `message-mark-insert-begin' and
`message-mark-insert-end'.  The function `message-mark-inserted-region',
whose default binding in Message mode is `C-c M-m', encloses the active
region between these two strings.

If the sender of a message marks a part of the message like this, and if
the recipient views the message as a Gnus article, then the marked text
appears in the face `mm-uu-extract'; on my dark background for Emacs,
the face has a dark green background, and a light yellow foreground.
This is the only highlighting that I see when I view Sharon's message.
I wonder if this is what Narendra meant by "syntax highlighted", or if
he meant something else.

Regards,
Raghu.

--
N. Raghavendra <[hidden email]>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/