Strona 2 z 2

Nienawiść do BBCode

: 31 sty 2020, 14:47
autor: Franklin Garamond

Ostatnia wiadomość z poprzedniej strony wątku

Helwetyk Romański pisze: ↑
31 sty 2020, 14:34
Na marginesie, czy ktoś w naszym gronie zna się na kawie w stopniu wykraczającym poza gatunki dostępne w sieciach?
A o co pytacie? Bo jeden znajomy to kawosz-hobbysta, a kilku profesjonalnych baristów znam (takich wygrywających zawody, a nie konkursy na pracownika roku w starbucksie) i nawet z nimi mieszkałem, więc jakaś wiedza pozostała.

Nienawiść do BBCode

: 31 sty 2020, 14:49
autor: Helwetyk Romański
Franklin Garamond pisze: ↑
31 sty 2020, 14:47
Helwetyk Romański pisze: ↑
31 sty 2020, 14:34
Na marginesie, czy ktoś w naszym gronie zna się na kawie w stopniu wykraczającym poza gatunki dostępne w sieciach?
A o co pytacie? Bo jeden znajomy to kawosz-hobbysta, a kilku profesjonalnych baristów znam (takich wygrywających zawody, a nie konkursy na pracownika roku w starbucksie) i nawet z nimi mieszkałem, więc jakaś wiedza pozostała.
Głośno zastanawiam się, czy nie dorzucić kawiarni do listy inicjatyw do uruchomienia…

Nienawiść do BBCode

: 06 lut 2020, 22:42
autor: Franklin Garamond
Zupełnym przypadkiem naszło mnie pod wieczór, by dodać do makra przekreślenie. Osobiście nie używam, ale może kiedyś komuś się przyda.

Swoją drogą dokumentacja do VBA jest bajeczna. https://docs.microsoft.com/en-us/office ... /overview/

Kod: Zaznacz cały

    Sub BBCode()
        Application.ScreenUpdating = False
        
        ConvertItalic
        ConvertBold
        ConvertUnderline
        ConvertStrikeThrough
        ConvertHyperlinks
        ConvertLists
        ConvertCenter
        
        ActiveDocument.Content.Copy
       
        Application.ScreenUpdating = True
    End Sub

    Private Sub ConvertCenter()
        ActiveDocument.Select
        Dim p As Paragraph
    
        For Each p In Selection.Paragraphs
        
            If p.Alignment = wdAlignParagraphCenter Then
                With p
                    If Len(p.Range.Text) > 1 Then
                        Set rng = ActiveDocument.Range(p.Range.Start, p.Range.End - 1)
                        rng.InsertBefore "[center]"
                        rng.InsertAfter "[/center]"
                     End If
                End With
            End If
        Next p
    End Sub
    
Private Sub ConvertLists()
    Dim l As List
    Dim p As Paragraph
    Dim curLevel As Integer
    Dim i As Integer
    Dim typeStack(10) As String ' hopefully lists aren't indented more than this
        
    curLevel = 1
        
    For Each l In ActiveDocument.Lists
        With l.Range
            For i = 1 To .ListParagraphs.Count
                Set p = .ListParagraphs(i)
                
                p.Range.InsertBefore "[*]"
                
                If p.Range.ListFormat.ListLevelNumber < curLevel Then
                    p.Range.InsertBefore "[/list" & typeStack(curLevel) & "]"
                    curLevel = curLevel - 1
                ElseIf p.Range.ListFormat.ListLevelNumber > curLevel Then
                    curLevel = curLevel + 1
                    typeStack(curLevel) = ExtractListSuffix(p.Range.ListFormat.ListString)
                    p.Range.InsertBefore "[list" & typeStack(curLevel) & "]"
                End If
            Next i
            
            Do While curLevel > 1
                .InsertAfter "[/list" & typeStack(curLevel) & "]"
                curLevel = curLevel - 1
            Loop
            
            Dim bullet As String
            
            bullet = ExtractListSuffix(l.Range.ListFormat.ListString)
            
            .InsertBefore "[list" & bullet & "]"
            .InsertAfter "[/list]" & vbCrLf
            .ListFormat.RemoveNumbers
        End With
    Next l
End Sub

Public Function ExtractListSuffix(bullet As String) As String
    bullet = Left$(bullet, 1)
    
    If InStr(1, "AI1", bullet, vbTextCompare) > 0 Then
        ExtractListSuffix = "=" & bullet
    Else
        ExtractListSuffix = ""
    End If
End Function

    Private Sub ConvertBold()
        ActiveDocument.Select
       
        With Selection.Find
       
            .ClearFormatting
            .Font.Bold = True
            .Text = ""
           
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
           
            .Forward = True
            .Wrap = wdFindContinue
           
            Do While .Execute
                With Selection
                    If InStr(1, .Text, vbCr) Then
                        ' Just process the chunk before any newline characters
                        ' We'll pick-up the rest with the next search
                              .Font.Bold = False
                        .Collapse
                        .MoveEndUntil vbCr
                    End If
                                           
                    ' Don't bother to markup newline characters (prevents a loop, as well)
                    If Not .Text = vbCr Then
                        .InsertBefore "[b]"
                        .InsertAfter "[/b]"
                    End If
                   
                    .Font.Bold = False
                End With
            Loop
        End With
    End Sub

    Private Sub ConvertItalic()
        ActiveDocument.Select
       
        With Selection.Find
       
            .ClearFormatting
            .Font.Italic = True
            .Text = ""
           
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
           
            .Forward = True
            .Wrap = wdFindContinue
           
            Do While .Execute
                With Selection
                    If InStr(1, .Text, vbCr) Then
                        ' Just process the chunk before any newline characters
                        ' We'll pick-up the rest with the next search
                        .Font.Italic = False
                        .Collapse
                        .MoveEndUntil vbCr
                    End If
                                           
                    ' Don't bother to markup newline characters (prevents a loop, as well)
                    If Not .Text = vbCr Then
                        .InsertBefore "[i]"
                        .InsertAfter "[/i]"
                    End If
                   
                    .Font.Italic = False
                End With
            Loop
        End With
    End Sub
    
    Private Sub ConvertUnderline()
        ActiveDocument.Select
       
        With Selection.Find
       
            .ClearFormatting
            .Font.Underline = True
            .Text = ""
           
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
           
            .Forward = True
            .Wrap = wdFindContinue
           
            Do While .Execute
                With Selection
                    If InStr(1, .Text, vbCr) Then
                        ' Just process the chunk before any newline characters
                        ' We'll pick-up the rest with the next search
                        .Font.Underline = False
                        .Collapse
                        .MoveEndUntil vbCr
                    End If
                                           
                    ' Don't bother to markup newline characters (prevents a loop, as well)
                    If Not .Text = vbCr Then
                        .InsertBefore "[u]"
                        .InsertAfter "[/u]"
                    End If
                   
                    .Font.Underline = False
                End With
            Loop
        End With
    End Sub
    
    Private Sub ConvertStrikeThrough()
        ActiveDocument.Select
       
        With Selection.Find
       
            .ClearFormatting
            .Font.StrikeThrough = True
            .Text = ""
           
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
           
            .Forward = True
            .Wrap = wdFindContinue
           
            Do While .Execute
                With Selection
                    If InStr(1, .Text, vbCr) Then
                        ' Just process the chunk before any newline characters
                        ' We'll pick-up the rest with the next search
                        .Font.StrikeThrough = False
                        .Collapse
                        .MoveEndUntil vbCr
                    End If
                                           
                    ' Don't bother to markup newline characters (prevents a loop, as well)
                    If Not .Text = vbCr Then
                        .InsertBefore "[strike]"
                        .InsertAfter "[/strike]"
                    End If
                   
                    .Font.StrikeThrough = False
                End With
            Loop
        End With
    End Sub

    Private Sub ConvertHyperlinks()
        'converts Hyperlinks
        '24-MAY-2006: only convert http..., mark others with error marker

    Dim hyperCount&
        Dim i&
        Dim addr$ ', title$

        hyperCount = ActiveDocument.Hyperlinks.Count

        For i = 1 To hyperCount

            With ActiveDocument.Hyperlinks(1) 'must be 1, since the delete changes count and position

                addr = .Address
                If Trim$(addr) = "" Then addr = "no hyperlink found"
                'title = .Range.Text
               
                'http, ftp
                If LCase(Left$(addr, 4)) = "http" Or LCase(Left$(addr, 3)) = "ftp" Then
                    .Delete 'hyperlink
                    .Range.InsertBefore "[url=" & addr & "]"
                    .Range.InsertAfter "[/url]"
                   
                    GoTo ConvertHyperlinks_Next
                End If
               
                'mailto:
                If LCase(Left$(addr, 7)) = "mailto:" Then
                    .Delete 'hyperlink
                    .Range.InsertBefore "[email]" & addr & " "
                    .Range.InsertAfter "[/email]"
                   
                    GoTo ConvertHyperlinks_Next
                End If
               
                'file guess
                If Len(addr) > 4 Then 'the reason for not nice goto
                    If Mid$(addr, Len(addr) - 3, 1) = "." Then
                        .Delete
                        .Range.InsertBefore "[file://" & Replace(addr, " ", "_") & " "
                        .Range.InsertAfter "]"
                       
                        GoTo ConvertHyperlinks_Next
                    End If
                End If
               
                'unidentified
                .Delete
                .Range.InsertBefore UnableToConvertMarker & "[" & addr & " "
                .Range.InsertAfter "]"

ConvertHyperlinks_Next:
            End With

        Next i

    End Sub

Nienawiść do BBCode

: 06 lut 2020, 22:59
autor: Helwetyk Romański
Franklin Garamond pisze: ↑
06 lut 2020, 22:42
Zupełnym przypadkiem naszło mnie pod wieczór, by dodać do makra przekreślenie.
Będzie testowane! 😍

Nienawiść do BBCode

: 23 sty 2024, 19:17
autor: Damiano Robingren
To teraz tylko czekać na konwerter z Markdowna do BBCode :3

Nienawiść do BBCode

: 23 sty 2024, 20:00
autor: Sheldon Anszlus Robingren
Nie ma to jak kopiować z Worda do BBcode 😂
Namiestnik zawsze miał dziwne fetysze 🍀

Nienawiść do BBCode

: 23 sty 2024, 20:52
autor: Caladea Cousine
Sheldon Anszlus Lovelace pisze: ↑
23 sty 2024, 20:00
Nie ma to jak kopiować z Worda do BBcode 😂
Tak naprawdę, to (a w sumie i każde) forum powinno mieć po prostu edycję postów WYSIWYG, z fallbackiem do edycji podzbioru HTML-a dla takich bez-JS-owych autystów jak ja. Wtedy mógłby tow. Elvetico Romanese sobie po prostu transferować posty z Worda do forum metodą (wcale nie smutnej) kopipasty.