File tree Expand file tree Collapse file tree 7 files changed +36
-2
lines changed
Expand file tree Collapse file tree 7 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ from textcase import case, convert
7272print (convert(" ronnie james dio" , case.SNAKE )) # ronnie_james_dio
7373print (convert(" Ronnie_James_dio" , case.CONSTANT )) # RONNIE_JAMES_DIO
7474print (convert(" RONNIE_JAMES_DIO" , case.KEBAB )) # ronnie-james-dio
75+ print (convert(" ronnie james dio" , case.MIDDOT )) # ronnie·james·dio
7576print (convert(" RONNIE-JAMES-DIO" , case.CAMEL )) # ronnieJamesDio
7677print (convert(" ronnie-james-dio" , case.PASCAL )) # RonnieJamesDio
7778print (convert(" RONNIE JAMES DIO" , case.LOWER )) # ronnie james dio
Original file line number Diff line number Diff line change 33print (convert ("ronnie james dio" , case .SNAKE ))
44print (convert ("Ronnie_James_dio" , case .CONSTANT ))
55print (convert ("RONNIE_JAMES_DIO" , case .KEBAB ))
6+ print (convert ("ronnie james dio" , case .MIDDOT ))
67print (convert ("RONNIE-JAMES-DIO" , case .CAMEL ))
78print (convert ("ronnie-james-dio" , case .PASCAL ))
89print (convert ("RONNIE JAMES DIO" , case .LOWER ))
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ def test_space() -> None:
1313 assert (boundary .SPACE ,) == tuple (boundary .get_boundaries (" " ))
1414
1515
16+ def test_interpunct () -> None :
17+ assert 0 == len (tuple (boundary .get_boundaries ("·" )))
18+
19+
1620def test_lower_upper () -> None :
1721 assert (boundary .LOWER_UPPER ,) == tuple (boundary .get_boundaries ("aA" ))
1822
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ def test_kebab() -> None:
1313 assert convert ("RONNIE_JAMES_DIO" , case .KEBAB ) == "ronnie-james-dio"
1414
1515
16+ def test_middot () -> None :
17+ assert convert ("ronnie james dio" , case .MIDDOT ) == "ronnie·james·dio"
18+
19+
1620def test_camel () -> None :
1721 assert convert ("RONNIE-JAMES-DIO" , case .CAMEL ) == "ronnieJamesDio"
1822
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ def test_kebab() -> None:
1616 assert is_case ("RONNIE_JAMES_DIO" , case .KEBAB ) is False
1717
1818
19+ def test_middot () -> None :
20+ assert is_case ("ronnie·james·dio" , case .MIDDOT ) is True
21+ assert is_case ("RONNIE_JAMES_DIO" , case .MIDDOT ) is False
22+
23+
1924def test_camel () -> None :
2025 assert is_case ("ronnieJamesDio" , case .CAMEL ) is True
2126 assert is_case ("RONNIE-JAMES-DIO" , case .CAMEL ) is False
Original file line number Diff line number Diff line change 88 "UNDERSCORE" ,
99 "HYPHEN" ,
1010 "SPACE" ,
11+ "INTERPUNCT" ,
1112 "LOWER_UPPER" ,
1213 "UPPER_LOWER" ,
1314 "ACRONYM" ,
@@ -69,7 +70,7 @@ def from_delimiter(delimiter: str) -> "Boundary":
6970
7071 This is a helper method that can be used to create simple boundaries such as
7172 [`UNDERSCORE`][textcase.boundary.UNDERSCORE], [`HYPHEN`][textcase.boundary.HYPHEN],
72- or [`SPACE`][textcase.boundary.SPACE].
73+ [`SPACE`][textcase.boundary.SPACE], or [`INTERPUNCT`][textcase.boundary.INTERPUNCT ].
7374
7475 **Unreleased.**
7576
@@ -105,11 +106,17 @@ def from_delimiter(delimiter: str) -> "Boundary":
105106"""
106107
107108SPACE : Final [Boundary ] = Boundary .from_delimiter (" " )
108- """Splits on space , consuming the character on segmentation.
109+ """Splits on ` ` , consuming the character on segmentation.
109110
110111**Added in version:** [`0.2.0`](https://zobweyt.github.io/textcase/changelog/#020-2025-04-01)
111112"""
112113
114+ INTERPUNCT : Final [Boundary ] = Boundary .from_delimiter ("·" )
115+ """Splits on `·`, consuming the character on segmentation.
116+
117+ **Unreleased**.
118+ """
119+
113120LOWER_UPPER : Final [Boundary ] = Boundary (
114121 satisfies = lambda text : text [0 :1 ].islower () and text [1 :2 ].isupper (),
115122 start = 1 ,
Original file line number Diff line number Diff line change 88 "SNAKE" ,
99 "CONSTANT" ,
1010 "KEBAB" ,
11+ "MIDDOT" ,
1112 "CAMEL" ,
1213 "PASCAL" ,
1314 "LOWER" ,
2526 DIGIT_LOWER ,
2627 DIGIT_UPPER ,
2728 HYPHEN ,
29+ INTERPUNCT ,
2830 LOWER_DIGIT ,
2931 LOWER_UPPER ,
3032 SPACE ,
@@ -99,6 +101,16 @@ class Case:
99101**Added in version:** [`0.2.0`](https://zobweyt.github.io/textcase/changelog/#020-2025-04-01)
100102"""
101103
104+ MIDDOT : Final [Case ] = Case (
105+ boundaries = (INTERPUNCT ,),
106+ pattern = lower ,
107+ delimiter = "·" ,
108+ )
109+ """Middot case strings are delimited by interpuncts `·` and are all lowercase.
110+
111+ **Unreleased.**
112+ """
113+
102114CAMEL : Final [Case ] = Case (
103115 boundaries = (
104116 LOWER_UPPER ,
You can’t perform that action at this time.
0 commit comments