• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Installing pandoc on Android?

carlosbcg

Lurker
Pandoc is a Linux (I think it runs on other OS's but I am using Linux) utility program that runs from the command line and can be used to generate HTML from Markdown documents.

I am trying to get it to run on my rooted Android phone so that I can create Markdown documents on my Android and convert them to HTML to view them.

I know there are a bunch of so-called Markdown editors in Android but quite frankly most all the one's I have tried are no good (at least not compared to Nocs under iPhone).

Anyway does anyone know how to run a command line tool like this under Android?

I tried copying the file to my Android and then tried running it from a command line terminal by entering "./pandoc" but Android tells me that I don't have permission to do that even as root.

There must be a way to do this as other utilities like ls, cat, and many others run just fine from a terminal command line.

I've Googled and Googled and can't find one single thing on using pandoc under Android.

Anybody know anything that might help me figure this out?

Thanks.

Carlos
 
Other *nix commands are either built in or, more commonly, emulated by a package called busybox (which as a rooted user you'll have met).

You say you've tried copying and running it, but what format is the thing you copied? A shell script, an x86 binary, or what? What libraries or functions does it depend on?

Though if it's saying you don't have permission to run it that sounds like you've not got to those problems yet (unless it's a misleading error message). I assume you used chmod to set the file's permissions before trying to run it?
 
Importing an x86 code and executing it on an ARM architecture - assuming that you could get past the header - would be disastrous. :D

I couldn't find source for it but if you could you could look into cross compiling.

What does Nocs do that Draft or MdReader doesn't?
 
Importing an x86 code and executing it on an ARM architecture - assuming that you could get past the header - would be disastrous. :D

I admit that I know next to nothing about ARM and Android internals. I mean I know it's Linux at it's core but in looking around and doing a lot of reading it's almost unrecognizable to me as Linux. It doesn't come with a native ability to have various users each with their own home directories. It doesn't seem to use sudo. Lots of other things that are different.

Even with BusyBox...the commands that are included through this App are part of this app and are not apparently available natively outside it. As one might have when running the terminal of one's choice under a regular Linux distribution.

I couldn't find source for it but if you could you could look into cross compiling.

The source is available at http://johnmacfarlane.net/pandoc/code.html

I believe pandoc is written in Haskell. As such I don't think it's going to be any easy task at all to cross compile it since the Haskell compiler has apparently not been ported to work under Android.

Come to think of it what I am trying to do....get the pandoc binary to run under Android...may not be possible in the sense that it was compiled to run under a different architecture.

I may have hit a wall here in that sense and there may be nothing I can do to get pandoc to run under Android.

What does Nocs do that Draft or MdReader doesn't?
[/quote]

Oh goodness. LOTS more.

Among those that I find incredibly useful.

Nocs allows me to designate CSS files for use in rendering the Markdown I create in individual directories as well as across all directories. I can edit the CSS files as readily as I can edit the Markdown files. NO Markdown capable editor under Android allows me to do that!

Nocs lets me generate the HTML so that I can more clearly see where a problem in rendering some HTML / Markdown code is at (by looking at the generated HTML).

Nocs lets me use tables in their Markdown. Every editor I have looked at under Android has failed on this point alone.

Nocs brings up a file in Preview mode already without my having to first edit a file and then push various buttons to get to a Preview. If I want to edit a file after I see it first in Preview then I can edit it. Very convenient.

Nocs lets me make various choices about it's Markdown compilation (interpretation would be more technically correct I think but still...) such as whether I want it to leave Markdown found inside HTML code blocks alone or not and other such options.

There are other advantages but those are some that are very handy.

Oh...I neglected to mention that Nocs is also free in it's basic version.

Under Android...there is NO markdown editor with all that.

But under Android I can also (if I can put the various pieces together) use Total Commander, Firefox, a simple text editor, a Markdown "compiler" like the excellent pandoc, bash scripts, and otherwise to put together my own Markdown document generating workflow.

And perhaps achieve something even better for my needs than Nocs and the iPhone allows.

Mind you Nocs is not the end all to using Markdown. But it is an excellent starting point and the main way I was creating Markdown documents on the go under iPhone. I would then transfer them to Linux periodically and use pandoc and various bash scripts I created to automatically generate or create new WordPress pages, PDF versions of my documents, EPUB versions of my documents, and so on.

I let pandoc do most of the heavy lifting. Then I would add awk and sed lines in my scripts to process the resulting HTML (when I wanted HTML) that pandoc generated a bit more to my liking. Spitting out a thing of beauty. Clean and well formatted without any extraneous HTML code snippets.

All from a master Markdown document.

That is what I am after doing under Android. So that I won't even have to transfer to Linux at all if I don't want to.

But I can't even get out of the starting gate with a robust and highly capable Markdown editor to begin with at this point.

I've thought of creating one but that is a bit more of an undertaking than I have time for just now so I was hoping to use pandoc and all the other tools under Android first.

Perhaps I am expecting too much of Android. Maybe I just need to accept that it's a far superior platform than iPhone for my purposes, use it as best I can, and continue the final processing of my Markdown writing under my Linux Mint install.

Carlos
 
Thanks for the markdown insights, I've never used it to that extent.

I agree, pandoc being a problem for porting. I'd gotten as far as http://johnmacfarlane.net/pandoc/ earlier (how not right? :D) but didn't go further.

I can jump start you on your crossover from desktop Linux to Android - so let's call that my best trade for the eye opener on what markdown can really do. :)

The Linux distributions you're accustomed to are really better described as GNU/Linux and have the hardware resources that need no further elaboration. And obviously, a number of open, quasi-private, and private extensions abound to shape personalization of your platform.

Comparing under those terms, Android is a compact, real-time Apache/Linux distribution, with a number of open and proprietary derivatives used as the final product you'll encounter.

You've encountered busybox as the replacement for a number of common building blocks for two reasons - limited hardware resources, and Apache licensing, not GPL, along with the massive changes that could be required to implement and fully elaborate the GNU versions.

The Android Linux kernel was originally branched, leading to religious arguments as to whether it could be called Linux with its number of changes off of the main line, but a few years ago, at rev 3 as memory serves, the Android Linux kernel rendezvoused with the main line, differences were reconciled and now Android changes are absorbed using the same procedures as for others.

I'm tempted to draw a comparison with the original minix not being able to support multiple users while the follow-on unix, a single user system, could, but that's really here just for comedy value.

Root privileges are prohibited to the user by design - carriers and makers do not generally want people mucking about, citing support as a valid issue, and danger to the telcos as an invalid one.

That said, the act of rooting does provide the exact analog to sudo from the common user perspective. That process entails adding the su-access binary library to a reserved /system folder, and superuser management access through a matching app. The su app in turn acts very much like a desktop Linux in that a user pop-up occurs when root access is requested by a process, allowing the user to grant always or once, or reject the request. The app then creates and maintains the equivalent of a sudoers file, but biased for just apps rather than users because of the single user nature of Android and the inherent trust in the owner that has purposely rooted the device.

Because of the compact, real-time nature of the system, X is completely missing and the ui/ux difference is highly non-trivial and its explanation leads to why Android is unlike earlier Linux phone systems.

Prior to Lollipop -

Android = compact, real-time Linux with (primarily Apache-licensed) library services + the Dalvik Virtual Machine (a sophisticated stack engine and far more than a JavaVM replacement) + apps that execute within the Dalvik and use kernel and system services

Most apps have been written in Java but not all. Native code apps exist, but nonetheless, received a wrapper in order to execute under Dalvik control and to follow the same architecture for an execution profile as Java apps.

Java apps were originally compiled at load time but in Gingerbread, the just in time compiler was introduced and non-native apps were incrementally compiled during execution.

The system proved highly effective and subtracting for compile time, Java apps (aka SDK-based apps) ran at the same speed as native code apps (aka NDK-based apps).

Lollipop formally replaced the Dalvik VM with the Android Runtime engine (ART). All SDK-based apps compile at installation time and essentially run the same as NDK-based based apps under ART, thereby allowing some users to experience performance improvements (depending on their personal app usage) while retaining the overall Android architecture.

Leading to the paradigm that everything the user sees is the result of an app for the majority of the experience, including the desktop and home screens - so where GNU/Linux has a desktop (usually founded in some way on X) and a window manager - Android has a launcher. To replace your desktop experience, replace the launcher by adding an app, same as you would for the dialer, browser, sms, or email app.

By the way, you can get the Terminal Emulator app and issue whatever built-in Linux-level commands you have installed. If rooted, rather than sudo, simply change to root with the su command and no arguments (same as you would on a desktop).

An sh is always there, busybox will give you a bash equivalent, or you can do as I did and install a better cross-compiled bash and use that.

That's the overview, hope it helps bridge the gap for you.
 
Thanks for your replies EarlyMon. Very insightful. Sorry I didn't get back to you sooner.

I am still in the process of banging my head against the proverbial wall when it comes to Android. While I have made great progress there is still very much left to be desired and a great deal of remaining confusion.

For example...

I have come to understand that apps under Android must be written in the Java language. Yet...there are some applications that seem to indicate that apps can be written in other languages like Javascript. I am talking full fledged APK packaged apps. One such app is called DroidScript. Why would I want to mess with the HUGE Android SDK, adb, and all that other stuff (which I have installed...have even gotten a hello world program to run on my Android but talk about HUGE overhead just to do that!) if I can write apps in much simpler Javascript without all the crazy overhead of Android SDK?

I have come to understand that programs running under my laptop Linux (64bit x86 architecture) won't run under the ARM architecture of Android without an ARM compiler for whatever language the Linux program is written in. Fair enough. But then...I install apps like Palapa Web Server which run MySQL, phpMyAdmin, Lighttpd, and PHP! What?

I mean how did they do that??!!! I seriously doubt that Palapa found an ARM compiler for all that.

And then there is the whole terminal thing on Android. It's not really a terminal. It's just another app with various stripped down "scripts" that one can run from it's command line interface. But...well...it seems to also be tied into some sort of hidden terminal that is native to Android. Or something. I don't know.

I've tried to run other apps from the terminal command prompt to no avail. So it's a command terminal but...well...not one at the same time?

Very confusing as to what is what.

It's kinda like Linux but then again it's not.

There is no .bashrc

The etc directory is inside /system

And even /system and it's subdirectories can't be written to unless one remounts it read/write.

Oh and not all editors can write to places like /system/etc/hosts

One needs a root capable editor (sheesh!). One cannot apparently use any app by calling it with a sudo type command. The app itself must have root capabilities I think.

The worst thing is that I have found NOTHING explaining what is what from an Android vs Linux perspective overall so that one could at least hope to use their Linux knowledge to get some handle on what Android is and how to do things under Android.

But I remain in the dark. Having to wing it. Spending countless hours fiddling with this or that. Trying this or that. Until something works.

And then...I often have no clue WHY it worked!

The text and programming editors under Android are terrible! Files get overwritten from editor buffers containing copies of the previously opened file, the little bookmark thingies move all over the place and are near impossible to control (compared to iPhone magnifying glass thingy), editors are missing buttons to save a file, others can only work with Dropbox, I can't change the default editor to open a certain type of file...on and on. Terrible. I've tried ALL the most popular one's and then many others that are obscure.

The best text editor I found so far isn't even a text editor. It's called WebMasterLite. But it's quirky and a bit difficult to work with in that windows open up and then you can't easily or at least intuitively close them again. There is also no Save menu option or button so I have to resort to Save As all the time.

But at least the bookmark thingies don't jump around as much in this editor as they do in others and I can reasonably select text in it. But it's still very quirky and cumbersome.

It's like editors in Android are not written for and by programmers but by people who simply want to make a buck from the market or something.

Very confusing and frustrating so far.

One very nice thing I found is sshfs. It mounts Android directories under my Linux laptop so that I can bring to bear on whatever files are in those directories the full power of my Laptop programs. Very sweet. You need to run an SSH server on Android and access it through a command line SSH call while both are connected to the same network but it works beautifully. Of course the downside is that I must be on my laptop.

I have been trying to move work to my Android so that I can be productive while on buses, at the beach, or wherever without having to pull out my laptop. So far...I have not yet been able to realize that much.

I looked at that full Linux (i.e. Ubuntu) on Android but for various reasons, not the least that it's more or less dying as an idea that Canonical still wants to pursue, it wasn't very workable.

Carlos
 
What's really neat about sshfs is that one can be accessing the files and directories on Android from a laptop like one can when connecting to PC under USB Storage option but completely independent of any such option.

So I can have Android connected to my laptop through a USB cable and charging it that way. Unplug it and connect it to a wall plug for faster charging. Have it plugged in nowhere.

Doesn't matter. The SSHFS mount continues uninterrupted until I am done with it. Or until I disconnect either the Android or Laptop from the network (i.e. wifi).

Carlos
 
You have to eat the elephant one bite at a time. :)

http://androidforums.com/threads/how-to-get-bash-in-terminal-emulator.576930/

You'll get a compact bash with busybox, either way you can use my method to get a bashrc.

You may be wrong-thinking part of app and terminal problem by not fully transitioning your perspective of a Linux without a window manager. I mean that only constructively ok and only based on a first read of your longer post.

SDK apps are written in Java. They compile on the fly pre-Lollipop and fully compile on installation.

That's why SDK apps tend to be most device portable.

The NDK supports a number of C species.

Not sure about Javascript but nothing would surprise me.

Either way, that's how you start with source and get ARM code.

You can roll your own Linux for Android without going near Canonical. I can probably dust off some brain cells and instruct on that but it's been 4 years and it's not for the faint-hearted so I make no promises.

That aside it sounds like you're well on your way to making some excellent finds and progress. :)
 
Back
Top Bottom