#! /bin/bash google() ( _is_slides() { echo "$@" | grep -q 'docs.google.com.presentation' } _is_sheets() { echo "$@" | grep -q 'docs.google.com.spreadsheets' } _is_doc() { echo "$@" | grep -q 'docs.google.com.document' } is() { _is_sheets "$@" || _is_doc "$@" || _is_slides "$@" } human_url() { echo "$1" } get() { local url="$1" local id="${url%/*}" id="${id##*/}" local downloaded="$(rclone get_google "$id")" echo "# ${downloaded##*/}" echo "" if [ "${downloaded##*.}" == "csv" ]; then _csv_to_md "$downloaded" elif [ "${downloaded##*.}" == "html" ]; then _html_to_md "$downloaded" else cat "$downloaded" fi } _html_to_md() { which pandoc &> /dev/null local f="$1" #log f=$f cat "$f" \ | sed 's/.*
.*/<\/body>/' \ | sed 's/<[\/]*span[^>]*>//g' \ | perl -pe 's|