rename dupes
This commit is contained in:
@@ -13,11 +13,12 @@ function clearsafe() {
|
||||
}
|
||||
SAFELOC=~/.cache/rm-safe
|
||||
FOLDERS=()
|
||||
QUIET="-q"
|
||||
[[ -z "$1" ]] && helpexit
|
||||
for ((i=1; i<=${#@}; i++)) {
|
||||
[[ "${!i}" = "-h" ]] && helpexit
|
||||
[[ "${!i}" = "--help" ]] && helpexit
|
||||
[[ "${!i}" = "-v" ]] && { VERBOSE=1; continue; }
|
||||
[[ "${!i}" = "-v" ]] && { VERBOSE=1; QUIET=""; continue; }
|
||||
[[ "${!i}" = "--clear" ]] && { clearsafe; continue; }
|
||||
[[ "${!i}" = "-"* ]] && helpexit
|
||||
FOLDERS+=( "${!i}" )
|
||||
@@ -28,8 +29,8 @@ for d in "${FOLDERS[@]}"; do
|
||||
if [[ ! -e "$d" ]]; then continue; fi
|
||||
path=$( readlink -f "$d" )
|
||||
dir=$( dirname "$path" )
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then echo "$path"; fi
|
||||
if [[ -e "$SAFELOC/$now/$path" ]]; then file-version -q "$SAFELOC/$now/$path"; fi
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then echo "$SAFELOC/$now/$path"; fi
|
||||
if [[ -e "$SAFELOC/$now/$path" ]]; then file-version $QUIET "$SAFELOC/$now/$path"; fi
|
||||
mkdir -p "$SAFELOC/$now/$dir"
|
||||
mv "$d" "$SAFELOC/$now/$dir"
|
||||
done
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
'''Markslider: a slideshow engine based on markdown.'''
|
||||
|
||||
__author__ = "Ville Rantanen <ville.q.rantanen@gmail.com>"
|
||||
__version__ = "1.1"
|
||||
__version__ = "1.2"
|
||||
|
||||
import sys,os,argparse,re,datetime
|
||||
from argparse import ArgumentParser
|
||||
@@ -105,6 +105,7 @@ class slide_reader:
|
||||
self.file_start_page.append(len(self.data))
|
||||
if len(self.data)==0:
|
||||
raise ValueError("File does not have a # header")
|
||||
self.rename_duplicates()
|
||||
self.toc()
|
||||
self.pages=len(self.data)
|
||||
self.inc_page_no(0)
|
||||
@@ -257,6 +258,23 @@ class slide_reader:
|
||||
return return_value
|
||||
# return [s]
|
||||
|
||||
def rename_duplicates(self):
|
||||
|
||||
if not opts.rename_title:
|
||||
return
|
||||
|
||||
titles = {}
|
||||
page_nos = []
|
||||
for page in self.data:
|
||||
if not page[0] in titles:
|
||||
titles[page[0]] = 0
|
||||
titles[page[0]] += 1
|
||||
page_nos.append(titles[page[0]])
|
||||
|
||||
for page, page_no in zip(self.data, page_nos):
|
||||
if titles[page[0]] > 1:
|
||||
page[0] += " [%d/%d]"%( page_no, titles[page[0]] )
|
||||
|
||||
|
||||
def get_interactive_help_text():
|
||||
return ''' left/right,page up/down,home,end
|
||||
@@ -308,6 +326,8 @@ Keyboard shortcuts:
|
||||
help="Disable color by markdown structure.")
|
||||
content.add_argument("--no-color","-n",action="store_false",dest="color",default=True,
|
||||
help="Disable color.")
|
||||
content.add_argument("--no-rename","--nr",action="store_false",dest="rename_title", default=True,
|
||||
help="Disable automatic renaming of duplicate titles.")
|
||||
|
||||
execution.add_argument("-e",action="store_true",dest="execute",default=False,
|
||||
help="Execute commands in `! or `> tags at show time with Enter key. WARNING: Potentially very dangerous to run others' slides with this switch!")
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user